📅  最后修改于: 2023-12-03 15:13:07.842000             🧑  作者: Mango
29_un21 is a Lua library that provides utility functions for working with Unicode characters and strings. Lua lacks native support for Unicode, so this library is intended to fill that gap.
The library is designed to be lightweight and efficient, and is compatible with Lua 5.1, 5.2, and 5.3.
The main features of 29_un21 are:
utf8.decode
and utf8.encode
.utf8.len
, utf8.sub
, and utf8.reverse
.unicode.normalize
and unicode.combining
.To use 29_un21, simply include the library in your Lua code:
local utf8 = require("29_un21.utf8")
Once you have included the library, you can use its functions like this:
local str = "𝔸𝕓𝕔"
print(utf8.len(str)) --> 3
print(utf8.sub(str, 2, 3)) --> "𝕓𝕔"
Here are a few examples of how you might use 29_un21 in your own Lua programs:
local utf8 = require("29_un21.utf8")
local str = "𝔸𝕓𝕔"
local len = utf8.len(str)
print("Number of characters: " .. len) --> "Number of characters: 3"
local utf8 = require("29_un21.utf8")
local str = "𝔸𝕓𝕔"
local rev = utf8.reverse(str)
print("Reversed string: " .. rev) --> "Reversed string: 𝕔𝕓𝔸"
local unicode = require("29_un21.unicode")
local str = "nöêl"
local nfc = unicode.normalize(str, "NFC")
print("NFC: " .. nfc) --> "NFC: nöêl"
29_un21 is a powerful and flexible library for working with Unicode characters and strings in Lua. Whether you need to parse text, count characters, or normalize strings, this library has you covered.
If you work with Lua and Unicode, you owe it to yourself to give 29_un21 a try!