utf8

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡。



API 參考
函式
char
utf8.char(codepoints:Tuple<number>):string
參數
codepoints:Tuple<number>
返回
範例程式碼
Utf8 字符

codes
utf8.codes(str:string):function,string,number
參數
str:string
範例程式碼
Utf8 代碼

codepoint
utf8.codepoint(
str:string, i:number, j:number
參數
str:string
預設值:1
預設值:i
返回
範例程式碼
Utf8 代碼點

len
utf8.len(
參數
預設值:1
預設值:-1
返回
範例程式碼
Utf8 長度

offset
utf8.offset(
參數
預設值:1
返回
範例程式碼
Utf8 偏移

graphemes
utf8.graphemes(
str:string, i:number, j:number
參數
str:string
返回
範例程式碼
Utf8 字形
-- "e" 後面跟著一個結合的尖音符是一個字形但兩個碼點
local str = "ae\u{0301}b"
print(utf8.len(str)) --> 4
for first, last in utf8.graphemes(str) do
local grapheme = string.sub(str, first, last)
print(first, last, #grapheme)
end
--> 1 1 1
--> 2 4 3
--> 5 5 1

nfcnormalize
utf8.nfcnormalize(str:string):string
參數
str:string
返回
範例程式碼
Utf8 NFC 正規化
local decomposed = "e\u{0301}" -- "e" 加上一個結合的尖音符號
local composed = utf8.nfcnormalize(decomposed)
print(utf8.len(decomposed)) --> 2
print(utf8.len(composed)) --> 1
print(composed == "\u{00E9}") --> true

nfdnormalize
utf8.nfdnormalize(str:string):string
參數
str:string
返回
範例程式碼
Utf8 NFD 正規化
local composed = "\u{00E9}" -- 預組合的 "é"
local decomposed = utf8.nfdnormalize(composed)
print(utf8.len(composed)) --> 1
print(utf8.len(decomposed)) --> 2
print(decomposed == "e\u{0301}") --> true

屬性
charpattern
utf8.charpattern:string
範例程式碼
Utf8 字符模式

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。