문제

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