如何在lua中编写unicode符号

前端之家收集整理的这篇文章主要介绍了如何在lua中编写unicode符号前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在lua中编写Unicode符号.例如,我必须用9658写符号
我写的时候
string.char( 9658 );

我收到了一个错误.那么如何编写这样的符号呢?

解决方法

Lua不看内部字符串.所以,你可以写
mychar = "►"

(2015年新增)

Lua 5.3引入了对UTF-8转义序列的支持

The UTF-8 encoding of a Unicode character can be inserted in a literal string with the escape sequence \u{XXX} (note the mandatory enclosing brackets),where XXX is a sequence of one or more hexadecimal digits representing the character code point.

你也可以使用utf8.char(9658).

原文链接:https://www.f2er.com/lua/274644.html

猜你在找的Lua相关文章