Neither of the Lua 5.3 or Lua 5.4 Compatibility sections mentions %z or \0, so presumably, both %z and \0 are supported, which kicks the can a long way. Anyway, users can always redefine utf8.charpattern as they wish.
( I was not entirely happy with Stepan's 'pragmatic' solution, but it will work for a long time. )
What do you think about getting the utf8lua.lua initialisation file to map all utf8 functions to the string library?
Then users do not need to worry about having to use utf8 functions such as utf8.upper(text) or utf8.len(text) because the string functions text:upper() or text:len() will work with any text strings and any existing scripts need not change.
e.g.
Code: Select all
-- utf8lua.lua initialisation file
utf8 = require(".utf8")
require("utf8data") -- As per utf8 library README.md Configuration: for lower and upper functions
utf8.config = { conversion = { uc_lc = utf8_uc_lc; lc_uc = utf8_lc_uc; } }
utf8:init()
for k,v in pairs(utf8) do string[k] = v end -- Map utf8 onto string for lower, upper, len, gsub, etc.