Problem with ios special characters

In my application, when I tried to set the attached string in UIlabel, special characters are not displayed. Please help me in solving this problem.

thanks

Result

Special character

+4
source share
4 answers

Using NSISOLatinStringEncoding solved this problem.

0
source

If you have a euro symbol on your keyboard, you can use it directly:

 [lLabel setText:@"€"]; 

Otherwise, use the Unicode escape code:

 [lLabel setText:@"\u20AC"]; 

ADDED The fundamental structure and the NSString class do not know screens, such as "¿euro", so you must replace them manually:

 NSString *s = @"abc ¿euro¿ def"; NSString *d = [s stringByReplacingOccurrencesOfString:@"¿euro¿" withString:@"\u20AC"]; 
+1
source

Hide the line in UTF-8, and then set the text for it with the text.

 [label setText:[NSString stringWithFormat:@"%s",[@"your_string" UTF8String]]]; 

[EDIT]

I tested this and worked great without converting the string to UTF-8!

 label.text = @"¿euro¿"; 

Check this output

Please make sure your server response is configured to UTF-8 and it should fix it. I had the same problem when I was receiving strings from the server in UTF8 - NSUTF8StringEncoding! I changed it and everything else worked fine!

For example, I do it like this:

 ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; request.defaultResponseEncoding = NSUTF8StringEncoding; 
0
source
 //Conevrt the string utf-8 format [yourstringvariabel UTF8String]; 
0
source

Source: https://habr.com/ru/post/1435886/


All Articles