NSLog outputs unicode characters as garbage when debugging on the iPhone
ios, iphone, nsstring, objective-c, xcode
Solution
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.
Problem
EDIT: NSLog output works well in the simulator, but doesn't work when connected to a real device. And it seems that it is a bug — http://openradar.appspot.com/11148883. Also it happens that it is related to the LLDB, switching Xcode to GDB resolves the problem. Either it's possible to JetBrain's AppCode, which works well with the LLDB. I have a bunch of unicode strings in the application, and if I try to output any of those strings using something like NSLog(@"%@", aString) then all the ASCII characters in the string will be printed fine but all the cyrillic letters will be messed up, so instead of ``` newLocation: coordinate:60.019584,30.284954 'Удельная' ``` I'm getting: ``` newLocation: coordinate:60.019584,30.284954 '–ü–æ–∫–ª–æ–Ω–Ω–æ–≥–æ—Ä—Å–∫–∞—è' ``` And that's quite hard to do any debugging with that kind of output. And because that app is targeted for the Russian market only I can't just change locale and use English strings. So I wonder if there any way to make NSLog work well with unicode characters? And I'm looking only for some kind of one-liner solution, I know that there are some ways to write half a page of code and output unicode chars, but I'm looking for something shorter. Ideally I'm looking for some method of NSString that will make it all work. e.g. ``` NSLog(@"%@", [aString someThingThatMakesUnicodeWorkWithXcodeConsole]); ```