In my app when i tried to set the attached string to the UIlabel special characters are not displaying. Please help me in solving this issue.
Thanks
In my app when i tried to set the attached string to the UIlabel special characters are not displaying. Please help me in solving this issue.
Thanks
If you have a Euro character on your keyboard, you can use it directly:
[lLabel setText:@"€"];
Otherwise use the Unicode escape:
[lLabel setText:@"\u20AC"];
ADDED The Foundation framework and the NSString class does not know escaping sequences like "¿euro¿", so you have to replace it manually:
NSString *s = @"abc ¿euro¿ def";
NSString *d = [s stringByReplacingOccurrencesOfString:@"¿euro¿" withString:@"\u20AC"];
Covert the string to UTF-8 and then set it to label text.
[label setText:[NSString stringWithFormat:@"%s",[@"your_string" UTF8String]]];
[EDIT]
I tested this and works fine without converting string to UTF-8!
label.text = @"¿euro¿";
Please make sure that your server's response set to UTF-8 and it should fix it. I had the same issue where I was getting strings from server in UTF8 - NSUTF8StringEncoding! I changed it and everything else worked fine!
For example I do it like:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
request.defaultResponseEncoding = NSUTF8StringEncoding;
Using NSISOLatinStringEncoding
solved this issue.