I'm using ABPeoplePickerNavigationController to let the user select an address. Everything works just fine in the Simulator. But if an address contains non-ASCII characters like "ü" the result is strange on my device. I have this code:
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
ABMultiValueRef addressesMultiValue = ABRecordCopyValue(person, property);
NSArray *addresses = (__bridge_transfer NSArray*)ABMultiValueCopyArrayOfAllValues(addressesMultiValue);
CFRelease(addressesMultiValue);
NSDictionary *addressData = [addresses objectAtIndex:0];
NSLog(@"%@", addressData);
NSArray *addressKeys = [[NSArray alloc] initWithObjects:(NSString*)kABPersonAddressStreetKey,
(NSString*)kABPersonAddressZIPKey,
(NSString*)kABPersonAddressCityKey,
(NSString*)kABPersonAddressStateKey,
(NSString*)kABPersonAddressCountryKey,
(NSString*)kABPersonAddressCountryCodeKey, nil];
NSMutableString *address = [[NSMutableString alloc] init];
for (NSString *key in addressKeys) {
NSString *object = [addressData objectForKey:key];
if (object) {
[address appendFormat:@"%@, ", object];
}
}
NSLog(@"%@", address);
The output for addressData is like this:
{
City = "M\U00fcnchen";
Country = Deutschland;
CountryCode = de;
Street = "Some street";
ZIP = 81000;
}
and the output for address is:
Some street, 81000, München, Deutschland, de,
The correct output for address would be "Some street, 81000, München, Deutschland, de, ". What puzzles me the most is, that \U00fc is the correct Unicode code point for "ü". I have tried many things including printing out every single unichar on its own, but the result doesn't change. Whatever I do when accessing the value in the NSDictionary seems to kill the Unicode character. What can I do to simply get the address correctly?
Thank you very much in advance!