Skip navigation.
 
mlRe: Unicode canonical decomposed form and text encoding
FROM : Renaud Boisjoly
DATE : Tue Jan 14 22:08:06 2003

Hi again

Ok, I think it will work, but I do have a last newbie question to ask
if I can...

I've managed to convert from the UniChar result to an NSString, but I'm
not clear on how to efficiently do the reverse. My original string is
in an NSString and I guess I need to convert it to UniChar... but being
pretty unexperienced, this looks like a mystery to me. Do I need to
iterate through each character using characterAtIndex and add them to
characters[] one by one? Should I use an NSScanner? Is there an
immensely obvious way to do this and I'm just not seeing it (probably).
I now its probably something I should know, but considering I've only
been programming for a year or so except for stuff like AppleScript, I
miss a lot of things.

My current idea is a for loop using characterAtIndex to add each
character...

Thanks for your time if you can afford it.

Renaud

On Tuesday, January 14, 2003, at 02:39  PM, Aki Inoue wrote:

> #import <Foundation/Foundation.h>
>
> static UniChar characters[] = ; // LATIN CAPITAL LETTER A WITH
> GRAVE
>
> #define MAX_BUFFER_LENGTH (100)
>
> int main (int argc, const char * argv[]) {
>    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
>    UnicodeToTextInfo textInfo;
>    UnicodeMapping mapping =
> {CreateTextEncoding(kTextEncodingUnicodeDefault,
> kTextEncodingDefaultVariant, kUnicode16BitFormat),
> CreateTextEncoding(kTextEncodingUnicodeDefault,
> kUnicodeCanonicalDecompVariant, kUnicode16BitFormat),
> kUnicodeUseLatestMapping};
>    UniChar buffer[MAX_BUFFER_LENGTH];
>    ByteCount inputRead, outputLen;
>    OSStatus status;
>
>    status = CreateUnicodeToTextInfo(&mapping, &textInfo);
>    if (noErr != status) {
>        NSLog(@"Failed to create UnicodeToTextInfo");
>        exit(1);
>    }
>
>    status = ConvertFromUnicodeToText(textInfo, sizeof(characters),
> characters, kTECKeepInfoFixMask, 0, NULL, NULL, NULL,
> MAX_BUFFER_LENGTH * sizeof(UniChar), &inputRead, &outputLen, buffer);
>    if (noErr != status) {
>        NSLog(@"Failed to convert string");
>        exit(1);
>    }
>
>    DisposeUnicodeToTextInfo(&textInfo);
>
>    [pool release];
>    return 0;
> }

_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlUnicode canonical decomposed form and text encoding Renaud Boisjoly Jan 14, 04:54
mlRe: Unicode canonical decomposed form and text encoding Aki Inoue Jan 14, 20:39
mlRe: Unicode canonical decomposed form and text encoding Renaud Boisjoly Jan 14, 20:45
mlRe: Unicode canonical decomposed form and text encoding Renaud Boisjoly Jan 14, 22:08
mlRe: Unicode canonical decomposed form and text encoding Clark S. Cox III Jan 14, 23:05
mlRe: Unicode canonical decomposed form and text encoding Dietrich Epp Jan 14, 23:13
mlRe: Unicode canonical decomposed form and text encoding Aki Inoue Jan 14, 23:44
mlRe: Unicode canonical decomposed form and text encoding Renaud Boisjoly Jan 15, 01:11
mlRe: Unicode canonical decomposed form and text encoding Aki Inoue Jan 15, 01:39
mlRe: Unicode canonical decomposed form and text encoding Renaud Boisjoly Jan 15, 02:26
mlRe: Unicode canonical decomposed form and text encoding Renaud Boisjoly Jan 15, 02:43
mlRe: Unicode canonical decomposed form and text encoding Aki Inoue Jan 15, 02:44
mlRe: Unicode canonical decomposed form and text encoding Renaud Boisjoly Jan 15, 02:57