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: Steve Checkoway <email@hidden>
- Date: Mon, 26 Jun 2006 08:21:47 -0700
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 );
}
--
Steve Checkoway
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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