Reputation: 87
hi i have a class that pulls all the contacts. in debugger i see phone number like this: phone String "\U0000202a+111 11‑11‑11111\U0000202c"
when i print it, it shows 111 11-11-11111.
because of this i cant do stringByReplacingOccurrencesOfString("-", withString: "", options: NSStringCompareOptions.RegularExpressionSearch, range: nil)
any idea why it gives me numbers like that , and is there a way to fix it ??
p.s = i use language that is right to left is it by any chance affects it
Upvotes: 0
Views: 94
Reputation: 180917
Yes, it's related to your right to left language. The codes are:
0x202a LEFT-TO-RIGHT EMBEDDING
...which tells the computer that the following string should go left to right.0x202c POP DIRECTIONAL FORMATTING
...which tells the computer to go back to the previous text direction.
As how to get rid of them I don't know any specific method, but you should be able to just use normal string manipulation to eliminate them if they exist.
EDIT: An example how you could trim them using stringByTrimmingCharactersInSet;
str = str.stringByTrimmingCharactersInSet(
NSCharacterSet(charactersInString: "\u{202a}\u{202c}"))
Upvotes: 2