Re: How to display Japanese in debug console?
Re: How to display Japanese in debug console?
- Subject: Re: How to display Japanese in debug console?
- From: "A.M." <email@hidden>
- Date: Mon, 26 Jun 2006 11:35:53 -0400 (EDT)
On Mon, June 26, 2006 11:21 am, Steve Checkoway wrote:
>
> On Jun 26, 2006, at 6:17 AM, Norio Ota wrote:
>
>>
>> ---------------- CocoaFunctions.h ----------------
>>
>>
>> #include <Carbon/Carbon.h>
>> #include <Cocoa/Cocoa.h>
>>
>>
>> extern void DebugStringInJP ( CFStringRef cfStr );
>>
>> ---------------- CocoaFunctions.m ----------------
>> #import "CocoaFunctions.h"
>>
>>
>> void DebugStringInJP ( CFStringRef cfStr ) {
>> NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
>> NSLog ((NSString*) cfStr);
>> [pool release];
>> }
>>
>
> First of all, if you're not using Cocoa for anything else, I wouldn't
> pull it in just for logging. Second, if I recall correctly, NSLog is
> variadic and as such you should probably write it as NSLog( @"%@", cfStr
> ). Third, why not just write your own?
>
>
> (Typed in mail while drunk.)
> void CFLog( CFStringRef fmt, ... ) {
> va_list ap; va_start( ap, fmt ); CFStringRef str =
> CFStringCreateWithFormatAndArguments( NULL, NULL,
> fmt, ap ); CFIndex length = CFStringGetLength( str );
> UInt32 encoding = kCFStringEncodingUTF8;
> CFIndex size = CFStringGetMaximumSizeForEncoding(length, encoding) + 1;
> char *buffer = (char *)malloc( size );
>
> CFStringGetCString( str, buffer, size, encoding );
> fputs( buffer, stderr ); // or stdout CFRelease( str );
> free( buffer ); }
All good advice, but why not simply use CFShow()?
http://gemma.apple.com/documentation/CoreFoundation/Reference/CFTypeRef/Reference/reference.html#//apple_ref/c/func/CFShow
-M
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden