Voloda2
Voloda2

Reputation: 12607

How do I log russian text or non-latin?

Everything works well in the previous version of XCode. But today in the XCode 4.3.2 I have a problem. How do I log russian text or non-latin?

NSLog(@"russian text: русский текст");

NSString *text = @"russian text: русский текст";
const char *textC = [text UTF8String];    
NSString *getText = [NSString stringWithCString:textC encoding:NSUTF8StringEncoding];
NSLog(@"___text: %@", getText);

My logs

russian text: —Ä—É—Å—Å–∫–∏–π —Ç–µ–∫—Å—Ç
___text: russian text: —Ä—É—Å—Å–∫–∏–π —Ç–µ–∫—Å—Ç

UPDATE:

The bug take place only on real device (ipod touch 5.1). It works properly on iphone simulator.

Upvotes: 1

Views: 1750

Answers (3)

Voloda2
Voloda2

Reputation: 12607

I found a solution. You need to change debugger from LLDB to GDB in Product->Edit Sheme. LLDB doesn't work correctly with russian language.

Upvotes: 1

pre
pre

Reputation: 3506

Update:

Works fine in Simulator for me.

However on a real device running iOS 5.1 I am getting the same wrong, disturbed output as you. So it probably is an XCode 4.3.2 bug.


I tested your code on XCode 4.3.2 and it works fine for me.

My logs:

2012-04-15 15:44:28.545 test[25799:15203] russian text: русский текст
2012-04-15 15:44:28.548 test[25799:15203] ___text: russian text: русский текст

Upvotes: 2

EricS
EricS

Reputation: 9768

Works fine for me in Xcode 4.2, so it's either a 4.3.2 bug or your source file encoding is wrong.

Check the "Preferences / Text Editing / Editing tab / Default text encoding" setting and make sure it's set to Unicode (UTF-8).

If it is, open the file in BBEdit and double check its encoding. It's possible there's an old MacRoman or other encoding set on the file.

Upvotes: 2

Related Questions