Re: Glyph's
Re: Glyph's
- Subject: Re: Glyph's
- From: Chris Ridd <email@hidden>
- Date: Sun, 27 Apr 2003 15:00:31 +0100
On 27/4/03 11:03 am, Mathew Peterson <email@hidden> wrote:
>
I have an old file (I assume encoded in NSMacOSRomanStringEncoding)
>
that I need to decode into something I can use in Cocoa (particularly a
>
string).
>
>
Now I have this code:
>
>
[stringOut setStringValue:[[[NSString alloc] autorelease]
>
initWithData:[[NSString stringWithFormat:@"ElE4E0Gh"]
>
dataUsingEncoding:NSMacOSRomanStringEncoding]
>
encoding:NSUnicodeStringEncoding]];
>
>
Which is a fragment of Glyph which spells out some Japanese characters.
>
I know the file is NSMacOSRomanStringEncoding because when I set my
>
string value with encoding NSUTF8StringEncoding it produces my glyph's.
>
I cannot for the life of me though get those Japanese characters to
>
display in their proper Unicode format. Btw, that glyph is KoNiChiWa
>
encoded.
>
>
Can anyone assist me?
You can only create static NSStrings using the @"..." construct if they are
7-bit US-ASCII strings. I'm not sure if you were expecting to be able to put
MacOSRoman-encoded characters in there or not; they didn't survive being
emailed.
There's no way to create truly static strings of arbitrary Unicode
characters, but there are a couple of workarounds that get you close:
1) calculate the UTF-8 encoding of your Unicode string, and use [NSString
stringWithUTF8String:]
2) build your string in an array of unichar, and then use [NSString
stringWithCharacters:length:]
3) build your string in an array of char, wrap it in an NSData and use
NSString's initWith
Data:encoding: to get an NSString.
Cheers,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: | |
| >Glyph's (From: Mathew Peterson <email@hidden>) |