starwing / luautf8

a utf-8 support module for Lua and LuaJIT.
MIT License
406 stars 67 forks source link

utf8.len(str) == nil #53

Open johnd0e opened 1 month ago

johnd0e commented 1 month ago

Many routines are the same as Lua's string module:

  • ...
  • utf8.len

In fact I see the difference when processing invalid utf8 strings:

local a = "\128\129\130"
print(utf8.len(a))
nil    1

This difference can lead to unobvious bugs.

So it must be either documented, or changed to throw error.