Handling special characters æ, ø, å in the c lens - iphone

I have a UILabel that I am modifying through code. However, when I create an NSString with charaters æ, ø, å (Danish), I get a warning about input conversion. The code is as follows:

NSString *label=[[NSString alloc]initWithFormat:@"Prøv igen"]; 

And the warning I get is a warning: the input conversion is stopped due to an input byte that does not belong to the UTF-8 input code. I can understand that ø is probably not UTF encoding, but what should I do? Anyone who can give me a hint on what to do to solve this problem?

Hello

Bjarke

+4
source share
3 answers

The source code is not saved as UTF-8, but most likely it is similar to ISO-8859-1.

Just open the file and save it as UTF-8 again - and while you are on it, you probably should also do this by default. Exactly how to do this depends on which editor you use.

+3
source

Make sure the encoding of the text file is set to UTF-8, not Western (ISO) or something else. You can use the Xcode file information inspector for this.

http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/XcodeWorkspace/050-File_Management/file_management.html%23//apple_ref/doc/uid/TP40002677-BABICEHI

Make sure it says Unicode (UTF-8) to encode files. If he asks you, tell him to re-interpret your file with the new encoding. Alternatively, you can remove the problematic text and re-download it to make it work.

+2
source

I had the same problem, but my source code files were already encoded in UTF-8, so I fix it differently. In your case, it would be something like

NSString * label = [NSString stringWithUTF8String "Prøv igen"];

I hope this will be useful to others who stumble over this question.

0
source

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


All Articles