Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7194405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:21:52+00:00 2026-05-28T20:21:52+00:00

I have a UTF-8 string which I want to display in an HITextView (MLTE)

  • 0

I have a UTF-8 string which I want to display in an HITextView (MLTE) control. Theoretically, HITextView requires either “Text” or UTF-16, so I’m converting:

UniChar uniput[STRSIZE];
ByteCount converted,unilen;

err = ConvertFromTextToUnicode(C2UInfo, len, output,
                               kUnicodeUseFallbacksMask, 0, NULL, 0, NULL,
                               sizeof(UniChar)*STRSIZE,
                               &converted, &unilen, uniput);
err=TXNSetData(MessageObject, kTXNUnicodeTextData, uniput, unilen, kTXNEndOffset,
               kTXNEndOffset);

I have defined the converter C2UInfo as follows:

UnicodeMapping    uMapping;
uMapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeV2_0,
                              kUnicodeCanonicalDecompVariant,
                              kUnicode16BitFormat);
uMapping.otherEncoding = GetTextEncodingBase(kUnicodeUTF8Format);
uMapping.mappingVersion = kUnicodeUseLatestMapping;
err = CreateTextToUnicodeInfo(&uMapping, &C2UInfo);

It works fine for plain old ASCII characters, but multi-byte UTF-8 is being mapped to the wrong characters. For example, æ (LATIN SMALL LETTER AE) is being mapped to 疆 (CJK UNIFIED IDEOGRAPH-7586).

I’ve tried checking and unchecking “Output Text in Unicode” in Interface Builder, and I’ve tried varying some of the conversion constants, with no effect.

This is being built with Xcode 3.2.6 using the MacOSX10.5.sdk and tested under 10.6.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:21:53+00:00Added an answer on May 28, 2026 at 8:21 pm

    The “Text” that ConvertFromTextToUnicode expects is probably the same “Text” that is one of your two options for MLTE. If you had the sort of “Text” that ConvertFromTextToUnicode converts from, you could just pass it to MLTE directly.

    (For the record, “Text” is almost certainly either MacRoman or whatever is dictated by the user’s locale-determined current script.)

    Instead, you should use a Text Encoding Converter. Create one, use it, finish using it, and dispose of it when you’re done.

    There are two other ways.

    One is to create a CFString from the UTF-8, then Get its characters. You would do this instead of using a TEC. It’s functionally equivalent and possibly a little bit easier. On the other hand, you don’t get to reuse the converter, for whatever that’s worth.

    The other, since you have an HITextView, would be to create a CFString from the UTF-8 and just use that. Like Cocoa objects, HIToolbox objects have an inheritance hierarchy; since an HITextView is a kind of HIView, HIViewSetText should just work. (And if not, try HIViewSetValue.)

    The last method also gets you that much closer to your eventual move away from MLTE/HITextView, since it’s essentially what you’ll do with an NSTextView. (HITextView and MLTE are deprecated.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have this code: String encoding = UTF-16; String text = [Hello StackOverflow];
I want to read UTF-8 strings from a server that I have control of,
Hello I have a bunch of text on my file which i display. I
I have to read a text file which is Unicode with UTF-8 encoding and
I have some graph, which I want to display using JUNG2 like in the
So I have a UTF-8 encoded string which can contain full-width kanji, full-width kana,
C# question here.. I have a UTF-8 string that is being interpreted by a
Say I have the following line in a method: String encodedString = URLEncoder.encode(foo, utf-8);
I have UTF-8 encoded NSData from windows server and I want to convert it
I have an UTF-8 encoded txt file and I want to import it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.