Onur Şahindur Onur Şahindur - 1 year ago 130
iOS Question

Weird \U0000202a and \U0000202c charachters?

I bumped into an interesting situation while I am writing an application about contact list.

The weird situation is that after I successfully managed to retrieve contacts from the iPhone's list, some phone numbers listed as;

@"\U0000202a xxx xxx xxxx\U0000202c".

When I try to use;

modifiedPN = [modifiedPN stringByReplacingOccurrencesOfString:@" " withString:@""];


modifiedPN = [modifiedPN stringByReplacingOccurrencesOfString:@"\\U0000202" withString:@""];

nothing changes.

I also tried

[mPN containsString:@" "]


[mPN containsString:@"\\U0000202"]

but they both returns "NO"

I think this problem occurs when user was saved from Whatsapp.

Does anyone know how to fix this issue?

I only want the phone number without spaces or weird \U0000202 charachter.

Answer Source

Go the other way and extract the number:

NSString *numString = @"\U0000202a 123 456 7890\U0000202c";

NSString *extractedString = [[numString componentsSeparatedByCharactersInSet:
                        [[NSCharacterSet decimalDigitCharacterSet] invertedSet]]

// extractedString = 1234567890

This also works with (123) 456 7890

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download