NSLog outputs unicode characters as garbage when debugging on the iPhone NSLog outputs unicode characters as garbage when debugging on the iPhone xcode xcode

NSLog outputs unicode characters as garbage when debugging on the iPhone


Yes, obviously you can create a string that will contain and output cyrillic letters. When I was learning Objective-C, I had the same problem in the begining(I'm as well was working with Russian words and stuff like that). So solution is to convert the string to other format like this:

NSString *string = [NSString stringWithCString:"Привет, как дела?" encoding:4];NSLog(@"%@", string);

or

NSString *string = [NSString stringWithUTF8String:"Этот вариант короче!"];NSLog(@"%@", string);

Hope it helps you!

P.S It means that you need to make create your strings as C-Style Strings, and set their encoding parameter to 4(UTF-8). You can see all list of avaliable parameters in the documentation to NSStringEncoding in NSString.


As far as I know it is relevant to NSLog() and LLDB on some Xcode versions. Have a try with one of these solutions:

  • Check log in Xcode Organizer >> Devices >> your device >> Console.
  • Use GDB as your debugger instead of LLDB if you are using the latter one. This can be changed from the schema options. Please refer to the steps in the comment by "cocos2d man" below.
  • Upgrade to Xcode 4.3.2. Some people say it solved this issue, but I haven't confirmed this myself.


Try to convert it in to UTF8 string.

NSString *str = [aString UTF8String] NSLog(@"%@", str);

Hope this helps.