# lua-resty-unicode **Repository Path**: perfgao/lua-resty-unicode ## Basic Information - **Project Name**: lua-resty-unicode - **Description**: 提供unicode编码字符串与utf-8编码字符串相互转换功能 - **Primary Language**: Lua - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 5 - **Forks**: 0 - **Created**: 2018-03-11 - **Last Updated**: 2021-06-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Name ==== lua-resty-unicode - 提供unicode编码与UTF-8编码字符串的相互转换功能。 Table of Contents ================= * [Name](#name) * [Status](#status) * [Synopsis](#synopsis) * [Require](#require) Status ====== 已经应用于生成环境. Require ======= * 依赖lua的bit库 1. 你可以在[LuaBitOp](http://bitop.luajit.org/download.html) 进行下载及编译,将编译后的**bit.so**放入LUA_PATH下即可。 2. 你也可以直接使用本库提供的**bit.so**。 Synopsis ======== ```lua local unicode = require "unicode" -- unicode to utf-8 print(unicode.decode('\\u0041')) -- A -- 支持url编码形式的转换: '%u' print(unicode.decode('%u0041')) -- A -- support mixing print(unicode.decode('s\\u0065l\\u0065ct * fr%u006fm')) -- select * from -- 各国文字的转换 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('بالعربية')) ``` ```bash 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 ```