方法
- C
- D
- T
常數
UNICODE_VERSION | = | RbConfig::CONFIG["UNICODE_VERSION"] |
實作支援的 |
執行個體公開方法
compose(codepoints) 連結
將分解的字元組合成組合形式。
來源: 顯示 | 在 GitHub 上
# File activesupport/lib/active_support/multibyte/unicode.rb, line 21 def compose(codepoints) codepoints.pack("U*").unicode_normalize(:nfc).codepoints end
decompose(type, codepoints) 連結
將組合的字元分解成分解形式。
來源: 顯示 | 在 GitHub 上
# File activesupport/lib/active_support/multibyte/unicode.rb, line 12 def decompose(type, codepoints) if type == :compatibility codepoints.pack("U*").unicode_normalize(:nfkd).codepoints else codepoints.pack("U*").unicode_normalize(:nfd).codepoints end end
tidy_bytes(string, force = false) 連結
將所有 ISO-8859-1 或 CP1252 字元替換成其 UTF-8 等效字元,產生一個有效的 UTF-8 字串。
傳遞 true
將強制整理所有位元組,假設字串的編碼完全是 CP1252 或 ISO-8859-1。
來源: 顯示 | 在 GitHub 上
# File activesupport/lib/active_support/multibyte/unicode.rb, line 30 def tidy_bytes(string, force = false) return string if string.empty? || string.ascii_only? return recode_windows1252_chars(string) if force string.scrub { |bad| recode_windows1252_chars(bad) } end