Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Converting ASCII input to UTF-8 for displaying
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting ASCII input to UTF-8 for displaying



Huyler, Christopher M wrote:
| Anyway, since all the strings are stored as ASCII, they are sent to the
| GUI over the socket as ASCII. When these dynamic strings are displayed
| in the GUI running on a Mac, the special characters come out garbled
| because the Mac assumes that they are UTF-8.

If the strings really *were* ASCII, there'd be no problem. The ASCII standard defines characters only for the codes between 0 and 127, inclusive. UTF-8 was designed to include the ASCII character set (the codes between 0 and 127) as a proper subset: any ASCII string is also a valid UTF-8 string. If you're getting things that come out garbled, then those characters are *not* ASCII. Hence your initial assumption--that the strings are plain ASCII--is incorrect.


| Any of the static strings that are compiled into the jar display fine so
| it is just these strings that come from the C/C++ backend that are
| garbled.
|
| My question is...
| Is there a way to convert these strings in Java?

The usual: determine the encoding of the (non-ASCII) eight-bit data, and run the data through a stream that understands that encoding.


Glen Fisher
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Converting ASCII input to UTF-8 for displaying (From: "Huyler, Christopher M" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.