Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 1.08 KB

README.md

File metadata and controls

55 lines (39 loc) · 1.08 KB

lua-utf8string

Simple UTF8 support in pure lua

Current Status

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.

Sample of use

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

TODO

  • See all other utf8 implementation
  • Try to follow the lua5.3's utf8 API
  • ...

License

My code is under MIT License