Professional Web Applications Themes

Converting to Unicode? - Mac Programming

I am writing a Carbon app that needs to convert to unicode from other encodings. I get the feeling that there are many messy old ways to do this and newer ways. Where should I be looking? In TextEncodingConverter.h? Or is there something better? There seems to be a mountain of doentation about this subject. If someone could cut through the fog and tell me where to look, I would appreciate it. If it is possible I want to convert a string of bytes from from EUC-JP to UTF-16. In TextCommon.h I found this define - it looks like what ...

  1. #1

    Default Converting to Unicode?


    I am writing a Carbon app that needs to convert to unicode from other
    encodings. I get the feeling that there are many messy old ways to do this
    and newer ways. Where should I be looking? In TextEncodingConverter.h? Or is
    there something better?

    There seems to be a mountain of doentation about this subject. If someone
    could cut through the fog and tell me where to look, I would appreciate it.

    If it is possible I want to convert a string of bytes from from EUC-JP to
    UTF-16.


    In TextCommon.h I found this define - it looks like what I want:

    kTextEncodingEUC_JP = 0x0920,
    /* ISO 646, 1-byte katakana, JIS 208, JIS 212*/



    Then for UTF-16 there are these??:

    kTextEncodingDefaultFormat = 0, /* Formats for Unicode & ISO 10646*/
    kUnicode16BitFormat = 0,


    Am I on the right track?

    Thanks.


    Bob Guest

  2. #2

    Default Re: Converting to Unicode?

    In article <BB6B4298.1E1F5%bobbob.bob>, Bob <bobbob.bob> wrote:
    > I am writing a Carbon app that needs to convert to unicode from other
    > encodings. I get the feeling that there are many messy old ways to do this
    > and newer ways. Where should I be looking? In TextEncodingConverter.h? Or is
    > there something better?
    >
    > There seems to be a mountain of doentation about this subject. If someone
    > could cut through the fog and tell me where to look, I would appreciate it.
    >
    > If it is possible I want to convert a string of bytes from from EUC-JP to
    > UTF-16.
    Something like this should work:

    CFStringRef str;
    str = CFStringCreateWithBytes(kCFAllocatorDefault, myEUCJPBytes,
    numBytes, kCFStringEncodingEUC_JP, false);
    if (str != NULL) {
    // Managed to create the string successfully
    CFIndex length = CFStringGetLength(str);
    UniChar *chars = (UniChar *) malloc(length * sizeof(UniChar));
    CFStringGetCharacters(str, CFRangeMake(0, length), chars);

    // We don't need this any more
    CFRelease(str);

    // Now chars is the UTF-16 data that corresponds to the
    // original bytes.
    ....
    }

    Hope this helps,
    Eric

    --
    Eric Albert [email]ejalbertstanford.edu[/email]
    [url]http://rescomp.stanford.edu/~ejalbert/[/url]
    Eric Albert Guest

Similar Threads

  1. Unicode
    By bharath in forum Web Design
    Replies: 7
    Last Post: February 22nd, 11:52 AM
  2. To Use Unicode or not?
    By UpstateWeb in forum Coldfusion Database Access
    Replies: 1
    Last Post: October 23rd, 05:08 PM
  3. C locale + unicode
    By John Sidney-Woollett in forum PostgreSQL / PGSQL
    Replies: 4
    Last Post: January 14th, 09:04 PM
  4. PHP and Unicode
    By Eric D. in forum PHP Development
    Replies: 1
    Last Post: November 1st, 01:11 PM
  5. LINGO AND UNICODE
    By bira in forum Macromedia Director Lingo
    Replies: 0
    Last Post: October 9th, 08:48 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139