Converting to Unicode?

Ask a Question related to Mac Programming, Design and Development.

  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 documentation 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. Similar Questions and Discussions

    1. Unicode
      I need your advise upon the issue we are facing in the Webexceller application. We have an application that supports the local languages (korean...
    2. PDETextAdd and Unicode
      Hi, All! I have a Japanese text in Unicode an I want to use it with PDETextAdd. The thing is that I need to convert it to the font encoding (the...
    3. To Use Unicode or not?
      I am posting this to hopefully help someone else with the same problem(s) and maybe get an answer? I recenlty updated from 4.5 to 6.1 and have...
    4. Arial Unicode MS
      I have a text string using Arial Unicode MS in Word which I want to cut and paste over to Illustrator 10. I have arial unicode ms installed on my PC,...
    5. PHP and Unicode
      Hi, I'm building a website that will use Unicode data. Back-end using PHP and SQL Server. The SQl Server database will store Unicode data...
  3. #2

    Default Re: Converting to Unicode?

    In article <BB6B4298.1E1F5%bob@bob.bob>, Bob <bob@bob.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 documentation 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]ejalbert@stanford.edu[/email]
    [url]http://rescomp.stanford.edu/~ejalbert/[/url]
    Eric Albert Guest

Posting Permissions

  • You may not post new threads
  • You may 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