Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting ASCII input to UTF-8 for displaying



I think what you meant to ask is, "How can I convert these weird windows strings into something meaningful on my Mac?" The answer is probably

new String(bytes, 0, bytes.length, "ISO8859_1");

It has nothing to do with UTF-8, except that you could have avoided these problems if you were using a modern encoding like UTF-8 in your database instead of crufty old ISO8859.1 (which has a pretty limited character set, and is going to be a problem as soon as you need to get translations to non-EU languages).

On Mar 29, 2004, at 4:33 PM, Huyler, Christopher M wrote:

We recently got our translated files back from the translators and are
now posed with the problem of converting the strings because some do not
display correctly on the Mac. Before you jump in and tell me to just
convert the string file and recompile let me explain how the product
works...

The bulk of the product is written in C/C++ and assumes ASCII encoding.
It creates logs that store information (among other things). Some logs
are kept in a database while others are just plain text files that are
opened and parsed. The product is supported on Windows, Netware, Linux,
Solaris, HPUX and soon Mac OS X. It follows a client/server
architecture where a server can view the logs of any of its clients.
The GUI is written in Java. Information is passed to the GUI using a
TCP/IP socket. By design, the GUI does not have to be run on the
machine you are connecting to (so it sort of creates a
double-client/server architecture).

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. 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?

--
Christopher Huyler
Computer Associates Intl.
mailto:email@hidden
_______________________________________________
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.


-Joshua
_______________________________________________
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.




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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.