Is there any Lua library that converts a string to bytes using UTF8 encoding?

前端 未结 3 1644
Happy的楠姐
Happy的楠姐 2021-02-14 10:28

I wonder whether this kind of library exists.

3条回答
  •  离开以前
    2021-02-14 11:08

    Lua 5.3 has UTF-8 support in the standard library now.

    For example, to get a UTF-8 string's code points:

    for p, c in utf8.codes("瑞&于") do
      print(c)
    end
    

    Output:

    29790
    38
    20110
    

提交回复
热议问题