I have a string with accent é within my database, when I take this string of there and saved it in a NSArray
instead of he save the string é it saves '\U00e9'.
If I put this string in a UITextField, the system places the string with accent. But this code has a problem! I need to send this string to another device (using a framework) and for that I do as follows:
NSData *data = [[NSData alloc] init];
data = [NSKeyedArchiver archivedDataWithRootObject:array];//The array contain the string in database
NSArray *arrayReceived = [NSKeyedUnarchiver unarchiveObjectWithData:data];
Inside NSArray
have the string \U00e9, but I need to save this string inside my database for this I must find some way to convert the string '\U00e9' to the string é before saving to the database again! How to do it?
You don't actually have a problem. Your é
and \u00e9
are the same thing, you can just think of them as being described in different ways.
See this page for a description of the unicode for é
.
Assuming that the framework / system that you send the encoded array to uses it in a sensible way (i.e. considering the unicode content) then you will be fine. The fact that you are using NSKeyedArchiver
to encode an NSArray
indicates that this is indeed the case.
Basically, just be aware that NSLog
and UI display are vert different things. NSLog
gives you a very raw view of data whereas UI gives you a human modified view of the data.