Swift3.0語言教程使用Unicode正規化標準化獲取字串
Swift3.0語言教程使用Unicode正規化標準化獲取字串
Swift3.0語言教程使用Unicode正規化標準化獲取字串,在NSString中可以使用4個屬性去使用Unicode正規化標準化獲取字串。這四個屬性分別為:decomposedStringWithCanonicalMapping、decomposedStringWithCompatibilityMapping、precomposedStringWithCanonicalMapping和precomposedStringWithCompatibilityMapping。
(1)decomposedStringWithCanonicalMapping屬性可以獲取一個字串,這個字串的內容是使用Unicode正規化D標準化獲取的。其語法形式如下:
var decomposedStringWithCanonicalMapping: String { get }
【示例1-22】以下將使用decomposedStringWithCanonicalMapping屬性獲取一個字串
import Foundation
var a=NSString(string: "Hello")
print(a.decomposedStringWithCanonicalMapping) //獲取字串
執行結果如下:
Hello
(2)decomposedStringWithCompatibilityMapping屬性可以獲取一個字串,這個字串的內容是使用Unicode正規化KD標準化獲取的。其語法形式如下:
var decomposedStringWithCompatibilityMapping: String { get }
【示例1-23】以下將使用decomposedStringWithCompatibilityMapping屬性獲取字串。
import Foundation
var a=NSString(string: "Hello")
print(a.decomposedStringWithCompatibilityMapping)
執行結果如下:
Hello
(3)precomposedStringWithCanonicalMapping屬性可以獲取一個字串,這個字串的內容是使用Unicode正規化C標準化獲取的。其語法形式如下:
var precomposedStringWithCanonicalMapping: String { get }
【示例1-24】以下將使用precomposedStringWithCanonicalMapping屬性獲取字串。
import Foundation
var a=NSString(string: "Hello")
print(a.precomposedStringWithCanonicalMapping)
執行結果如下:
Hello
(4)precomposedStringWithCompatibilityMapping屬性可以獲取一個字串,這個字串的內容是使用Unicode正規化KC標準化獲取的。其語法形式如下:
var precomposedStringWithCompatibilityMapping: String { get }
【示例1-25】以下將使用precomposedStringWithCompatibilityMapping屬性獲取字串。
import Foundation
var a=NSString(string: "Hello")
print(a.precomposedStringWithCompatibilityMapping)
執行結果如下:
Hello
Swift3.0語言教程使用Unicode正規化標準化獲取字串
推薦閱讀: Swift3.0語言教程獲得一個公共的字首
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29597077/viewspace-2127974/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Swift3.0語言教程獲取C字串Swift字串
- Swift3.0語言教程使用指標建立和初始化字串Swift指標字串
- Swift3.0語言教程使用字串建立和初始化字串Swift字串
- Swift3.0語言教程字串大小寫轉化Swift字串
- 資料庫標準化與正規化資料庫
- Swift3.0語言教程使用編碼建立和初始化字串Swift字串
- Swift3.0語言教程獲取字串長度Swift字串
- Swift3.0語言教程使用URL字串Swift字串
- Swift3.0語言教程使用佔位符格式建立和初始化字串Swift字串
- Swift3.0語言教程使用路徑字串Swift字串
- Reactive設計語言與正規化React
- Swift3.0語言教程組合字串Swift字串
- 資料的標準化與正則化
- Swift3.0語言教程獲取字串編碼與雜湊地址Swift字串編碼
- Swift3.0語言教程分割字串與擷取字串Swift字串
- Swift3.0語言教程替換子字串Swift字串
- Swift3.0語言教程比較、判斷字串Swift字串
- SEO優化獲取精準流量優化
- 關於使用sklearn進行資料預處理 —— 歸一化/標準化/正則化
- 【原】關於使用sklearn進行資料預處理 —— 歸一化/標準化/正則化
- 資料庫設計正規化2——BC正規化和第四正規化資料庫
- 再談程式設計正規化—程式語言背後的思想程式設計
- 程式設計正規化 —— 函數語言程式設計入門程式設計函數
- mysql 正規化和反正規化MySql
- 正規表示式獲取兩個字元之間的字串資訊字元字串
- 標準c語言03C語言
- - C語言標準庫C語言
- 標準C語言4C語言
- 標準C語言5C語言
- 標準C語言1C語言
- 標準C語言2C語言
- 資料庫(第一正規化,第二正規化,第三正規化)資料庫
- Swift3.0語言教程字串轉換為數字值Swift字串
- Python 快速教程(標準庫01):正規表示式 (re包)Python
- C語言的本質(22)——C標準庫之字串操作C語言字串
- 前端資料正規化化前端
- 資料庫原理之第一正規化、第二正規化、第三正規化資料庫
- C語言系列之 指標強化與應用視訊教程C語言指標