Question

How would you add superscript inside an NSLocalized string?

I'm trying to write a superscript 2, if I do it like this, it works:

[title setText:[NSString stringWithFormat:@"CO\u00B2 %@",NSLocalizedString(@"c04View01_title", @"Title for current page")]];

But if I add the superscript to the localized string, it doesn't work, it just interprets that as 5 characters:

"c04View01_title" = "CO\u00B2 PROGRAMMERS";

[title setText:NSLocalizedString(@"c04View01_title", @"Title for current page")]];

The problem happens, when the string with the superscript is between strings, so I need to split the string in two parts, but in some languages the superscripted string ends up at the end of the sentence.

Était-ce utile?

La solution

Try using an upper-case 'U' for the backslash-escape, as per Apple's documentation:

"c04View01_title" = "CO\U00B2 PROGRAMMERS";

You can also just put the character directly in the strings file, un-escaped. There is no need to backslash-encode most characters.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top