Similar to question but with \u{e2}
symbol (fix is the same):
\u{e2}
is not a character rather subset of UTF8 plane which starts with 0xE2
byte.
So look here, E2 are general punctuation symbols.
There many symbols actually which started with \u{e2}
but not limited to it and full char can be represented f.e. with e2 80 a8
bytes (line separator).
That explains why shown in Xcode \u{e2}
can't be replaced with replacingOccurrences
... function. In order to filter out correct symbol you have to know what exact symbol it is, f.e. by using the snippet below:
"\u{2028}&😲".forEach { (char) in
print(Data(char.utf8).map { String(format: "%02x", $0) }.joined(separator: " "))
}
it prints to console:
e2 80 a8
26
f0 9f 98 b2
which are byte representation for each symbol.
Next step is to filter your string, go here and search in 3d column your bytes and unicode code point value is what you need (first column) and write it in swift code like "\u{2028}\u{206A}..."
(depending on your sorting).
The final function may look like:
func removingE2Symbols() -> String {
let specialChars = "\u{202A}\u{202C}"
return filter { !specialChars.contains($0) }
}
\u{ef}
, or the code point U+00EF LATIN SMALL LETTER I WITH DIAERESIS? – Saldivartext?.replacingOccurrences(of: "\\u{ef}"...
with double backslash. – Saldivar\{ef}
. Try removing\u{FFFC}
instead, or check what is the actual extra character by puttingprint(text.data(using: .utf8) as! NSData)
. – Totem