Skip to content

tst2005/lua-utf8string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

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

About

[#####] Simple UTF8 support in pure lua

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages