Re: japanese characters in document based application
Re: japanese characters in document based application
- Subject: Re: japanese characters in document based application
- From: Satoshi Matsumoto <email@hidden>
- Date: Mon, 13 Sep 2004 17:53:10 +0900
Hi Julien,
There are several kinds of encodings in Japanese characters, such as:
UTF-8 (NSUTF8StringEncoding),
shift-JIS, (NSShiftJISStringEncoding)
ISO-2022JP (NSISO2022JPStringEncoding),
EUC-JP (NSJapaneseEUCStringEncoding)
and others.
To handle the Japanese characters correctly, you must know the encoding you
are going to handle.
If your "theData" and the Japanese characters are both in UTF-8, the
solution is simple.
[theData appendBytes:<the pointer of Japanese characters>
length<length of Japanese characters>];
But If the Japanese charactes is not in UTF-8, you should convert them to
UTF-8 encoding as follows.
// convert original Japanese characters to NSString
NSString *tempString =[[NSString alloc]
initWithBytes:<the pointer of Japanese characters>
length<length of Japanese characters>
encoding:<the character encoding of Japanese characters>];
// convert it to utf-8 data
NSData *utf8Data = [tempString dataUsingEncoding:NSUTF8StringEncoding];
//then append it to your "theData"
[theData appendData:utf8Data];
[tempString release];
Hope that helps.
Satoshi Matsumoto
on 04.9.13 4:55 PM, Julien Palmas at email@hidden wrote:
> my document based app deals with japanese characters.
> the nsdata returned after the dataRepresentation contains some japanese
> characters added to the data like this :
> [theData addBytes:[@"the japanese character" cString] length:[@"the
> japanese character length"];
>
> when i a do :
> [theData writeToFile:@"/file" automically:NO]; there is no pb. the file
> contains what i want.
>
> but in my document based app, the dataRepresentation methods, that
> returns the data fails saying that encoding my japanese characters is
> not doable. error number is 30.
>
> how can i deals with this encoding ???
>
> thanks
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
-----------------------------------------------------
Satoshi Matsumoto <email@hidden>
816-5 Odake, Odawara, Kanagawa, Japan 256-0802
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden