关于字符串
'a'# >> 取字符a的ASCII值97
'abc'# >> 取首个字符a的ASCII值97
'UTF16字符串'u >> utf-16 LE编码(代码页:1200)字符串
'UTF8字符串'u8 >> utf-8 编码(代码页:65001)字符串
'\u0061\u0062\u0063' >> utf-16 LE编码(代码页:1200)字符串
gbk: 936
utf-8: 65001
utf-16: 1200
字符串形式:
str = 'abcd
\"\nefgh' >> abcd"换行efgh //多行不换行,内部转义,\"输出"
str = "abcd
""\nefgh" >> abcd换行"\nefgh //多行换行,不转义,""输出"
str = //abcdefgh\n >> abcdefgh\n //单行注释内容,不转义
str = /*abcd\n
efgh*/ >> abcd\n回车换行efgh //多行注释内容,不转义
经典案例:
for( chr='A'#; 'Z'# ) {
str = string.pack( chr )
io.print( str, str[1], chr, str[[1]] ); //猜猜输出结果是什么?---------------------------A 65 65 A -> Z 90 90 Z
}