Search code examples
iosobjective-cnslocalizedstringchinese-localensstringencoding

Special - Chinese characters in string


I am doing language translation in code.

self.title.text = [NSString stringWithFormat:NSLocalizedString(@"Q%ld", nil), (long)quizNumber];

I have added localization which works fine in French case but in Chinese '%ld' comes on the screen.

If I put the chinese string in place of english string, I get error "data argument not used by format string"

Any pointers? Should I use some kind of encoding?


Solution

  • I have done localisation in my app in Chinese as well, no problem so far, but I use mostly %d, not %ld.

    Can you try using %d instead?

    self.title.text = [NSString stringWithFormat:NSLocalizedString(@"Q%d", nil), (int)quizNumber];
    

    Take a look at https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html