Skip to content

perfgao/lua-resty-unicode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

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

About

unicode to utf-8 or utf-8 to unicode

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages