string.len("база") return 8 in gideros. And any other cyrillic combination will return doubled number. With latin works fine. I thought that may be it is ok in Lua, but in Quick works fine... So it is gideros bug.
its not a bug. unless it is bug in standard lua interpreter (library liblua). in short > You might want to know how many Unicode characters are in a string. Depending on the encoding used, a single Unicode character may occupy up to four bytes.
By default in Lua string.len in this case should return how many bytes string occupies, to get size for buffer, etc. And it's doing just that, so maybe it's a bug in Quick
I used this lib in my Rebus game. Looks like it fit to this problem too. If anybody will need it - file attached to message. May be Quick has some sort of autodetect... curiously...
Gideros always saves the files in UTF-8 format. For Quick, I think there are two possibilities: 1. You've used a encoding like http://en.wikipedia.org/wiki/ISO/IEC_8859-5 other than UTF-8. 2. Quick has modified string.len (and other string functions) to work with UTF-8 seamlessly.
Hello Here is a solution which works for me for getting correct unicode string length
-- Return the character count in a unicode string wordfunction wordLength( word )local wordlength =0for c instring.gmatch(word, ".")doif(string.byte(c)<128orstring.byte(c)>191)then--print("c "..string.byte(c))
wordlength = wordlength + 1endendreturn wordlength
end
Comments
in short
> You might want to know how many Unicode characters are in a string. Depending on the encoding used, a single Unicode character may occupy up to four bytes.
for more information see http://lua-users.org/wiki/LuaUnicode
I know I'm not being helpful, just the fact
http://stackoverflow.com/questions/10097941/print-number-of-characters-in-utf-8-string
So basically you'd need a specific library to deal with unicode strings, I just don't know any of them, maybe someone else will.
May be Quick has some sort of autodetect... curiously...
Likes: bali001
1. You've used a encoding like http://en.wikipedia.org/wiki/ISO/IEC_8859-5 other than UTF-8.
2. Quick has modified string.len (and other string functions) to work with UTF-8 seamlessly.
But it's a big library and its binaries takes about ~2MB.
According to lua.org, the following should work:
Is Gideros perhaps using an outdated library?
Here is a solution which works for me for getting correct unicode string length
https://itunes.apple.com/en/developer/unal-zubari/id953453674