Reputation: 1048
I'm having trouble with special characters (like â é ü) when using a custom font in my app.
For some reason, it's replacing the accented characters with seemingly random characters. I'm trying to set a UILabel
's text to the word Château but both this:
myLabel.text = [NSString stringWithFormat:@"Château"];
and (
myLabel.text = [NSString stringWithFormat:@"Ch\u00E1teau"];
are setting the label text to Ch,teau. This is only happening when using the custom font, when I log the result in the console the correct character shows up. I've tried setting a different string encoding. These characters so exist within the font (if i type the same word in TextEdit, MS Word, etc it shows up fine), I've also validated and inspected the font in FontBook. It's an .OTF font.
Any ideas what's happening?
Upvotes: 1
Views: 3653
Reputation: 41642
Try:
[NSString stringWithFormat:@"Ch\u00E1teau"]
Note the forward slash was changed to a backslash.
PS: verified in real program.
Upvotes: 1
Reputation: 2936
Not all font sets have all characters. Open the charactermap in windows load your custom font and see if it exists. It could be that the author of the font has in advertantly placed it at the wrong code.
Upvotes: 3