lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 14/09/2013 13:49, Alexander Gladysh wrote:
Hi, list!

$ lua -l unicode
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
=unicode.utf8.format("|%5s|", "12345")
|12345|
return unicode.utf8.format("|%5s|", "12")
|   12|
return unicode.utf8.format("|%5s|", "абвгд")
|абвгд|
return unicode.utf8.format("|%5s|", "абв")
|абв|
return unicode.utf8.format("|%5s|", "аб")
| аб|

It seems that length in bytes is used instead of length in characters.

Judging from the code here, string is simply formatted using
non-unicode-aware s[n]printf:

https://github.com/LuaDist/slnunicode/blob/master/slnunico.c#L1227

You can take a look at our fork [1] of this library (the issue in question is fixed there).

[1] http://farmanager.com/svn/trunk/plugins/luamacro/luafar/slnunico.c

--
Shmuel