删除 Unicode U+2018 左单引号,如 ‘Ali to Ali in swift
Removing Unicode U+2018 LEFT SINGLE QUOTATION MARK like ‘Ali to Ali in swift
如何从 -
等字符串中删除 Unicode U+2018 左单引号
Ghulam ‘Ali, ‘Ali Khel, ‘Ali Sher ‘Alaqahdari.
我想删除出现的‘A || '一个|| '你|| ‘u在一个字符串中分别为A a U u.
我试过了
var myString = "Sozmah Qal‘ah"
var diacriticRemovedString = myString.folding(options: .diacriticInsensitive, locale: Locale.current)
print(diacriticRemovedString)
但是没用。
由于 U+2018 字符未被视为变音符号,您可以简单地搜索此类字符并将其删除。
这是删除变音符号和这些特定引号的 Swift 4 版本(如您的原始问题中所述):
var myString = "Sozmah Qal‘ah"
var diacriticRemovedString = myString.folding(options: .diacriticInsensitive, locale: Locale.current).replacingOccurrences(of: "‘", with: "")
print(diacriticRemovedString)
输出:
Sozmah Qalah
如何从 -
等字符串中删除 Unicode U+2018 左单引号Ghulam ‘Ali, ‘Ali Khel, ‘Ali Sher ‘Alaqahdari.
我想删除出现的‘A || '一个|| '你|| ‘u在一个字符串中分别为A a U u.
我试过了
var myString = "Sozmah Qal‘ah"
var diacriticRemovedString = myString.folding(options: .diacriticInsensitive, locale: Locale.current)
print(diacriticRemovedString)
但是没用。
由于 U+2018 字符未被视为变音符号,您可以简单地搜索此类字符并将其删除。
这是删除变音符号和这些特定引号的 Swift 4 版本(如您的原始问题中所述):
var myString = "Sozmah Qal‘ah"
var diacriticRemovedString = myString.folding(options: .diacriticInsensitive, locale: Locale.current).replacingOccurrences(of: "‘", with: "")
print(diacriticRemovedString)
输出:
Sozmah Qalah