結構
Unicode
Unicode.CanonicalCombiningClass
Unicode 標準定義的規範排序算法中使用的標量分類。
聲明
struct CanonicalCombiningClass
概述
排序算法使用規範組合類來確定兩個組合標記序列是否應被視為規範等效(即解釋相同)。如果兩個序列在按組合類以升序對標量進行排序時相等,則它們是規範等價的。
例如,考慮序列"\u{0041}\u{0301}\u{0316}"
(拉丁文大寫字母 A,組合重音,下麵組合重音)。這些標量的組合類分別具有數值 0、230 和 220。通過它們的組合類對這些標量進行排序產生 "\u{0041}\u{0316}\u{0301}"
,因此僅通過這些標量的順序不同的兩個字符串將比較為相等:
let aboveBeforeBelow = "\u{0041}\u{0301}\u{0316}"
let belowBeforeAbove = "\u{0041}\u{0316}\u{0301}"
print(aboveBeforeBelow == belowBeforeAbove)
// Prints "true"
命名和未命名的組合類
規範組合類在 Unicode 標準中定義為 0...254
範圍內的整數。為方便起見,該標準將符號名稱分配給這些組合類的子集。
CanonicalCombiningClass
類型符合 RawRepresentable
類型的原始值 UInt8
。您可以使用以符號名稱命名的靜態成員或使用 init(rawValue:)
初始化程序來創建該類型的實例。
let overlayClass = Unicode.CanonicalCombiningClass(rawValue: 1)
let overlayClassIsOverlay = overlayClass == .overlay
// overlayClassIsOverlay == true
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
相關用法
- Swift Unicode.CanonicalCombiningClass ...(_:_:)用法及代碼示例
- Swift Unicode.CanonicalCombiningClass ..<(_:)用法及代碼示例
- Swift Unicode.CanonicalCombiningClass ..<(_:_:)用法及代碼示例
- Swift Unicode.CanonicalCombiningClass ...(_:)用法及代碼示例
- Swift Unicode.Scalar.UTF16View contains(where:)用法及代碼示例
- Swift Unicode.Scalar.UTF8View dropFirst(_:)用法及代碼示例
- Swift Unicode.Scalar.UTF16View firstIndex(of:)用法及代碼示例
- Swift Unicode.Scalar.UTF16View randomElement()用法及代碼示例
- Swift Unicode.Scalar.UTF8View contains(where:)用法及代碼示例
- Swift Unicode.UTF32 encode(_:into:)用法及代碼示例
- Swift Unicode.Scalar.UTF16View forEach(_:)用法及代碼示例
- Swift Unicode.Scalar.UTF8View index(_:offsetBy:limitedBy:)用法及代碼示例
- Swift Unicode.Scalar.UTF16View allSatisfy(_:)用法及代碼示例
- Swift Unicode.Scalar.UTF8View elementsEqual(_:)用法及代碼示例
- Swift Unicode.Scalar.UTF16View prefix(through:)用法及代碼示例
- Swift Unicode.Scalar.UTF8View split(maxSplits:omittingEmptySubsequences:whereSeparator:)用法及代碼示例
- Swift Unicode.Scalar escaped(asASCII:)用法及代碼示例
- Swift Unicode.Scalar.UTF16View contains(_:)用法及代碼示例
- Swift Unicode.Scalar.UTF16View filter(_:)用法及代碼示例
- Swift Unicode.Scalar.UTF16View split(separator:maxSplits:omittingEmptySubsequences:)用法及代碼示例
- Swift Unicode.Scalar.UTF16View enumerated()用法及代碼示例
- Swift Unicode.Scalar.UTF16View reduce(into:_:)用法及代碼示例
- Swift Unicode.Scalar.UTF8View allSatisfy(_:)用法及代碼示例
- Swift Unicode.UTF16 transcodedLength(of:decodedAs:repairingIllFormedSequences:)用法及代碼示例
- Swift Unicode.UTF16 trailSurrogate(_:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Unicode.CanonicalCombiningClass。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。