0

I successfully post and receive data by using RestKit. For example, I can easily decode this response (it is the debug output from RestLog):

 response.body={
    "response":
      {"fields":{"name":"test"}}
    }

But when the data contains accents, the response is encoded weardly:

response.body={
"response":
  {"fields":{"name":"\u00c3\u00a8\u00c3\u00a8"}}
}

and then my mapping is wrong. The mapping is done as usual:

@property (nonatomic, copy) NSDictionary *fields;

I extract the fields from the response and then do the mapping.

 mappingDict = @{  @"fields"       :@"fields" };
 responseMapping = [RKObjectMapping mappingForClass:[SynchObj class]];
 [responseMapping addAttributeMappingsFromDictionary:mappingDict];

How to handle accents?

gdm
  • 7,647
  • 3
  • 41
  • 71
  • How are you mapping (what to)? The accents are just part of the string so should be constrained to string processing after the mapping has completed. – Wain Jan 13 '14 at 13:44
  • So what, specifically, is wrong. The dictionary is not set? Or the string inside is corrupted somehow? How are you using the dictionary contents? – Wain Jan 13 '14 at 14:50
  • What is wrong is the coding: there is a way to handle escaped chars or I have to change the remote WS? – gdm Jan 13 '14 at 15:36
  • If the original string is UTF-16 or something then you just need to know the encoding. Strings will usually be assumed to be UTF-8 and should just work when displayed. If escaping has been applied at the server then you need to explicitly de-escape before you use it (after mapping). – Wain Jan 13 '14 at 15:56

0 Answers0