1 Star 5 Fork 0

perfgao / lua-resty-unicode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
README-en.md 1.57 KB
一键复制 编辑 原始数据 按行查看 历史
perfgao 提交于 2018-03-11 13:43 . adjust README

Name

lua-resty-unicode - This library provides the mutual conversion of Unicode and UTF-8.

Table of Contents

Status

This library is production ready.

Require

  • bit library
  1. Download from LuaBitOp and compile.
  2. Or you can use the 'bit.so' provided by the library itself

Synopsis

local unicode = require "unicode"

-- unicode to utf-8
print(unicode.decode('\\u0041'))    -- A

-- support url-encode: '%u'
print(unicode.decode('%u0041'))     -- A

-- support mixing
print(unicode.decode('s\\u0065l\\u0065ct * fr%u006fm'))  -- select * from

-- A variety of encoding text
print(unicode.decode('%u0045%u006e%u0067%u006c%u0069%u0073%u0068'))
print(unicode.encode('English'))

print(unicode.decode('\\u6c49\\u5b57'))
print(unicode.encode('汉字'))
print(unicode.decode('\\u6f22\\u5b57'))
print(unicode.encode('漢字'))

print(unicode.decode('\\u0440\\u0443\\u0441\\u0441\\u043a\\u0438\\u0439\\u0020\\u0020\\u0442\\u0435\\u043a\\u0441\\u0442'))
print(unicode.encode('русский  текст'))

print(unicode.decode('\\u0628\\u0627\\u0644\\u0639\\u0631\\u0628\\u064a\\u0629'))
print(unicode.encode('بالعربية'))
A
A
select * from
English
\u0045\u006e\u0067\u006c\u0069\u0073\u0068
汉字
\u6c49\u5b57
漢字
\u6f22\u5b57
русский  текст
\u0440\u0443\u0441\u0441\u043a\u0438\u0439\u0020\u0020\u0442\u0435\u043a\u0441\u0442
بالعربية
\u0628\u0627\u0644\u0639\u0631\u0628\u064a\u0629
Lua
1
https://gitee.com/perfgao/lua-resty-unicode.git
git@gitee.com:perfgao/lua-resty-unicode.git
perfgao
lua-resty-unicode
lua-resty-unicode
master

搜索帮助