Debugger console encoding in XCode is broken

拈花ヽ惹草 提交于 2020-01-06 19:45:08

问题


Non-latin text outputs very strange way in XCode debug console. How make it right?

For example: Проверьте давление экрана. became –ü—Ä–æ–≤–µ—Ä–∫–∞ –¥–∞–≤–ª–µ–Ω–∏—è —ç–∫—Ä–∞–Ω–∞

(Help me please improve my question because my english is not good. Let me know If it's hard to understand what I wrote here.)

- (id) initWithDictionary:(NSDictionary*)dictionary
{
    //...
    self.title = [dictionary objectForKey:@"Заголовок"] ; // dictionary from plist encoded in UTF8
    //...
    return self;
}
- (void) log
{
    NSString *class = NSStringFromClass([self class]);
    NSString *sel   = NSStringFromSelector(_cmd);
    NSLog(@"%@:%@:%@", class, title_, sel);
}

title_ is iVar NSString loaded from plist. It's used as title of uiviewcontroller and works fine on iPhone & iPad.


回答1:


Since I changed debugger from lldb to gdb output had become OK. So, something wrong must be with lldb.

In xcode 4: Menu -> Product -> Manage Schemes... Then tap Edit button -> Run Your.app (Left panel) -> Debugger -> change it from LLDB to GDB.




回答2:


I thought this wouldn't be a problem as of Xcode 3 but I guess I thought wrong.

Ugly trick for logging: Maybe try NSString's -cStringUsingEncoding: with different logging format to try to force the correct encoding to be displayed. I don't know if this will work:

NSLog(@"%S", [title_ cStringUsingEncoding:NSUnicodeStringEncoding]);


来源:https://stackoverflow.com/questions/10950805/debugger-console-encoding-in-xcode-is-broken

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!