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: Mac Character encoding



Mike wrote:

>I have a client that's attempting to output Swedish
>text characters that he's entered into my app's
>interface, to HTML documents.
>
>Unfortunately the HTML encoding that is supported
>(<meta http-equiv="content-type"
>content="text/html;charset=ISO-8859-1">) is currently
>not transforming his native language charset
>correctly.
>
>All of this is working fine on the PC. The PC Java
>environment outputs the data in the correct encoding
>type so that it can be interpreted by the iso-8859-1
>enabled browser.

It's probably working on the PC because 8859-1 is often the default
text-encoding on Windows.  Java's default text-encoding is specified as the
"file.encoding" system property.  If that's what's happening, it's working
by accident.

What you probably need to do is specify 8859-1 as the output text-encoding,
rather than relying on the platform-dependent default.

Exactly how to do that, I can't tell you, because you don't say how you're
outputting your HTML documents.

If you're using FileWriter, then switch to a FileOutputStream within an
OutputStreamWriter where you specify the text-encoding as "8859-1".  See
the constructors of OutputStreamWriter for details.

If you're using FileOutputStream already, then what methods do you write
the HTML text with?

Or are you using a String method that converts text chars to bytes, and
writing the bytes?

If you're using String.toBytes(), then switch to the method that takes a
text-encoding arg, and specify "8859-1".


>What is the Mac encoding charset type? If there is
>one, Can it be interpreted using safari?

If I understand those questions correctly, the answers are:
  1) in Java, "file.encoding" is MacRoman by default on Mac OS X.
  2) yes, if you specify "charset=MacRoman" in the HTML.

Not sure how helpful those answers are, because I think they're missing the
basic point that you should take control of the text-encoding written to
the file, rather than relying on the platform-dependent default.

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



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.