Simple UTF8 support in pure lua
The module emulate the string capabilities
-
string.byte
-
string.char
-
string.dump
-
string.find
-
string.format
-
string.gmatch
-
string.gsub
-
string.len
-
string.lower
(*) -
string.match
-
string.rep
-
string.reverse
-
string.sub
-
string.upper
(*)
(*) don't thread Unicode, only ascii upper/lower cases.
local u = require("utf8string")
local data = "àbcdéêèf"
local udata = u(data)
print(type(data), data) -- the orignal
print(type(udata), udata) -- automatic convertion to string
print(#data) -- is not the good number of printed characters on screen
print(#udata) -- is the number of printed characters on screen
print(udata:sub(4,5)) -- be able to use the sub() like a string
- See all other utf8 implementation
- Try to follow the lua5.3's utf8 API
- ...
My code is under MIT License