lua-users home
lua-l archive

Re: Lua 5.1.4 with Traditional Chinese

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


On 12/01/2015 04:50, tjhack wrote:
Hi all,
I convert some lua script(it contains chinese character) from simplified chinese to traditional chinese, and now the chinese character is encoding with cp950.
Now I switch my win7 machine locale to zh_TW, and restart. Everything seems okay, the script with traditional chinese character is correct displayed.
But when I complied these script.It is error.Invalid escape string.
for example:
msg="外功系普攻攻擊" print(msg)
the result is:
外巨t普攻攻擊
Look at the hex of the string, it is
\xa5~\xa5\\\xa8t\xb4\xb6\xa7\xf0\xa7\xf0\xc0\xbb
so it is the lua not escape the string.
Now the problem is, can I solve it? How can I let the script compile success? My source script can not encoding into utf-8, if can, it is esay.‍
Probably you should encode your UTF-8 characters with escape sequences inside strings, because Lua opens files for parsing in text mode, and thus relies on the underlying C text mode file handling routines. UTF-8 files may not reach the parser unaltered, depending on the transformations done by the C routines (which are NOT UTF-8 aware). Lua 5.3 may help you a bit, since it introduces new UTF-8 escape sequences: in Lua 5.3 you may enter the encoding of a Unicode code-point directly as \u{NNN} instead of typing the corresponding encoded sequence as possibly several \xNN escapes.
Thanks.
‍
-- Lorenzo

AltStyle によって変換されたページ (->オリジナル) /