starwing / luautf8

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

utf8.len(str) == nil #53

Open johnd0e opened 2 months ago

johnd0e commented 2 months 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.