开源软件名称(OpenSource Name):Stepets/utf8.lua开源软件地址(OpenSource Url):https://github.com/Stepets/utf8.lua开源编程语言(OpenSource Language):Lua 99.6%开源软件介绍(OpenSource Introduction):utf8.luapure-lua 5.3 regex library for Lua 5.3, Lua 5.1, LuaJIT This library provides simple way to add UTF-8 support into your application. Example:local utf8 = require('.utf8'):init()
for k,v in pairs(utf8) do
string[k] = v
end
local str = "пыщпыщ ололоо я водитель нло"
print(str:find("(.л.+)н"))
-- 8 26 ололоо я водитель
print(str:gsub("ло+", "보라"))
-- пыщпыщ о보라보라 я водитель н보라 3
print(str:match("^п[лопыщ ]*я"))
-- пыщпыщ ололоо я Usage:This library can be used as drop-in replacement for vanilla string library. It exports all vanilla functions under local utf8 = require('.utf8'):init()
local str = "пыщпыщ ололоо я водитель нло"
utf8.gsub(str, "ло+", "보라")
-- пыщпыщ о보라보라 я водитель н보라 3
utf8.raw.gsub(str, "ло+", "보라")
-- пыщпыщ о보라보라о я водитель н보라 3 It also provides all functions from Lua 5.3 UTF-8 module except Please note that library assumes regexes are valid UTF-8 strings, if you need to manipulate individual bytes use vanilla functions under Installation:Download repository to your project folder. (no rockspecs yet) Examples assume library placed under As of Lua 5.3 default Configuration:Library is highly modular. You can provide your implementation for almost any function used. Library already has several back-ends:
Probably most interesting customizations are local utf8 = require('.utf8')
utf8.config = {
cache = my_smart_cache,
}
utf8:init() For local utf8 = require('.utf8')
utf8.config = {
conversion = {
uc_lc = utf8_uc_lc,
lc_uc = utf8_lc_uc
},
}
utf8:init() Customization is done before initialization. If you want, you can change configuration after Documentation:Issue reporting:Please provide example script that causes error together with environment description and debug output. Debug output can be obtained like: local utf8 = require('.utf8')
utf8.config = {
debug = utf8:require("util").debug
}
utf8:init()
-- your code Default logger used is |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论