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 and getInputStream()




On Jan 27, 2007, at 3:27 AM, Martin Edling Andersson wrote:

I want to process input from a unix command i my java application. The problem is that characters such as å, ä and ö come out all wrong. After reading other messages on the mailinglist I suppose input is in MacRoman.

The code:
Process pAllMounted = Runtime.getRuntime().exec("ls /Volumes/");
BufferedReader stdInput = new BufferedReader(new InputStreamReader(pAllMounted.getInputStream(), "MacRoman"));
BufferedReader stdError = new BufferedReader(new InputStreamReader(pAllMounted.getErrorStream(), "MacRoman"));

The result:
The character "å" becomes a\xcc\x8a and the character "ä" becomes o\xcc\x8 and so forth.

I've tried with other character encodings for .getInputStream but so far none has decoded the characters correctly. Now I have to loop through the input and replace all occurences.

Anyone got any suggestions?

I believe you should try UTF-8 for that type of input source.

-Shawn
 _______________________________________________
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

References: 
 >Mac character encoding and getInputStream() (From: Martin Edling Andersson <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.