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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SEO優化獲取精準流量優化
- 一門多正規化的程式語言Scala學習收尾-函式的使用函式
- 關於使用sklearn進行資料預處理 —— 歸一化/標準化/正則化
- 程式設計正規化 —— 函數語言程式設計入門程式設計函數
- 再談程式設計正規化—程式語言背後的思想程式設計
- 標準C語言1C語言
- 標準C語言2C語言
- 標準C語言4C語言
- 標準C語言5C語言
- 標準c語言03C語言
- 從Google網頁中透過正規表示式獲取json如何轉換unicode物件Go網頁JSONUnicode物件
- 正規表示式獲取兩個字元之間的字串資訊字元字串
- C語言系列之 指標強化與應用視訊教程C語言指標
- go語言標準庫 - timeGo
- go語言標準庫 - strconvGo
- go語言標準庫 - regexpGo
- go語言標準庫 - logGo
- C語言知識彙總 | 51-C語言字串指標(指向字串的指標)C語言字串指標
- 新型大語言模型的預訓練與後訓練正規化,谷歌的Gemma 2語言模型模型谷歌Gemma
- 新型大語言模型的預訓練與後訓練正規化,Meta的Llama 3.1語言模型模型
- 前端資料正規化化前端
- JavaScript 獲取瀏覽器的所使用語言JavaScript瀏覽器
- 使用Profile標準化資料庫管理資料庫
- 新型大語言模型的預訓練與後訓練正規化,阿里Qwen模型阿里
- 正規化判斷
- 獲取系統語言/當前 App支援語言APP
- Git Commit 標準化GitMIT
- 新型大語言模型的預訓練與後訓練正規化,蘋果的AFM基礎語言模型模型蘋果
- e語言 取文字右邊的字串字串
- 在 ISO C90 標準中 C 語言負數比正數大?
- 使用ORACLE ASMFD配置ORACLE儲存標準化OracleASM
- JavaScript獲取給定字元的unicodeJavaScript字元Unicode
- go語言獲取外部引數Go
- RFC6020 - YANG語言標準中文
- 正規表示式中使用變數擷取某字串前後內容變數字串
- 標準化/結構化 JSON 輸出JSON
- weblogic JDBC標準化效能最佳化WebJDBC
- selenium模組,web自動化,獲取標籤頁Web
- MySQL 三大正規化MySql