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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top