Re: ASL & Unicode in Xcode's Console
Re: ASL & Unicode in Xcode's Console
- Subject: Re: ASL & Unicode in Xcode's Console
- From: Jason Coco <email@hidden>
- Date: Tue, 28 Oct 2008 16:03:28 -0400
On Oct 28, 2008, at 14:01 , Karl Moskowski wrote:
I've been experimenting with replacing my app's logging with Apple
System Logger. When it comes to multi-byte characters, every thing
looks OK in Console.app. However, Xcode's console shows things
incorrectly. It probably won't come up often, but I'm wondering if
it's fixable.
For example, this bit of code:
NSLog(@"あ");
aslclient client = asl_open(NULL, NULL, ASL_OPT_STDERR); // add
STDERR's fd to the connection's set of fds so things show up in
Xcode's console
asl_log(client, NULL, ASL_LEVEL_ERR, "あ");
asl_close(client);
Results in this output in Xcode:
2008-10-28 13:49:19.767 ASL[3484:10b] あ
Tue Oct 28 13:49:19 iMac.local ASL[3484] <Error>: \M-c\M^A\M^B
The call to NSLog displays correctly, but asl_log doesn't.
This is a known issue... you can see where the mangling happens in the
source code online when writing to stderr... the characters
are properly encoded when sent to syslog and will show up correctly in
asl queries and the console application, as you saw. I output
japanese to logs a lot and have never really had a problem, except
that during debugging I have to use console in those cases and
not rely on general output. There are a number of bug reports on the
issue, but I doubt it's a very high priority since it write the log
to the database correctly.
If you absolutely need this functionality, it's actually encoding it
in some visual encoding form (you can see more about the form
in the source code) so you could, in theory, handle it if you had to.
Also, you should not be using non-ascii characters in string
literals :) hopefully you're just doing this to demonstrate the issue.
You should
be doing something like this:
char *hiragana_a = { 0xE3, 0x81, 0x82, 0x00 };
NSLog(@"%@", [NSString stringWithCString:a
encoding:NSUTF8StringEncoding]);
asl_log(client, NULL, ASL_LEVEL_ERR, a);
:) J
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden