I am getting a json response from a web service and sticking it in a nsdictionary. Some characters like ™ and ® are coming across as Unicode characters. Is there an easy way to convert those characters to UTF8 so they don't display with weird characters in the UI?
Edit: I am using JSONKit to parse the JSON to dictionarys. The JSON looks like the following from the web service.
{
"Name":"Test â¢"
}
When I log the dictionary I get Name = "Test \U00e2\U0084\U00a2";
- (void)getProductsFavorties:(NSDictionary *)params
{
[self setNetworkQueue:[ASINetworkQueue queue]];
[[self networkQueue] setQueueDidFinishSelector:@selector(queueFinished:)];
NSString *getProductsFavortiesURL = [NSString stringWithFormat:@"%@%@", GET_PRODUCTS_FAVORTIES, [params objectForKey:@"loginkey"]];
NSLog(@"getProductsFavortiesURL: %@", getProductsFavortiesURL);
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:getProductsFavortiesURL]];
[request setDelegate:self];
[request setDidFinishSelector:@selector(getProductsFavortiesFinished:)];
[request setDidFailSelector:@selector(getProductsFavortiesFailed:)];
[request addRequestHeader:@"Content-Type" value:@"application/json"];
[request addRequestHeader:@"Accept" value:@"application/json"];
[request setRequestMethod:@"GET"];
[request setTimeOutSeconds:10];
[[self networkQueue] addOperation:request];
[[self networkQueue] go];
}
- (void)getProductsFavortiesFinished:(ASIHTTPRequest *)request
{
if ([[self networkQueue] requestsCount] == 0) {
[self setNetworkQueue:nil];
}
// Handle success
NSString *theJSON = [request responseString];
NSDictionary *productFavouriteResponse = [theJSON JSONValue];
if ([productFavouriteResponse objectForKey:@"AuthResponse"] && [productFavouriteResponse objectForKey:@"data"] && [productFavouriteResponse objectForKey:@"data"] != [NSNull null]) {
[[NSNotificationCenter defaultCenter] postNotificationName:GET_PRODUCTS_FAVORTIES_SUCCESS_NOTIFICATION object:productFavouriteResponse];
} else {
[[NSNotificationCenter defaultCenter] postNotificationName:GET_PRODUCTS_FAVORTIES_FAILURE_NOTIFICATION object:productFavouriteResponse];
}
}
Now I can get the result dictionary value from [productFavouriteResponse objectForKey:@"Name"] and stick that into a uilabel and I get "Test â¢"