NSString and Foreign characters

Discussion in 'Mac Programming' started by varsis, Jan 29, 2008.

  1. varsis macrumors regular

    Nov 30, 2005

    I have a NSString which is formated using a stringWithFormat, but when I pass a foreign character in it goes weird.

    Characters like ö,

    they mess it right up. Is I use NSLog, it will show the right character, but if you put this into an NSString it goes wonk.
  2. Bakerman macrumors member

    Jan 31, 2005
    Use [NSString stringWithUTF8String:"..... ö ....."]. Note the absence of the @ before the string, and make sure that the file encoding of your source file is UTF8.

    Or use a strings file and the NSLocalizedString macro family.
  3. gnasher729 macrumors P6


    Nov 25, 2005
    When you ask for programming help, remember that there are quite a few capable programmers here, but very very few good mind readers. How are we supposed to figure out what your problem is? As a good exercise for a beginner, what about a post where you describe exactly what you are doing. Like: What are you doing? What do you expect to happen? What happens?

    You should check out the documentation. You should especially check the page with format specifiers, and you should know the difference between %c and %C, and the difference between %s, %S and %@. It would also be great if you would know what the difference between "string" and @"string" is.

Share This Page