Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Mac character encoding and getInputStream()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mac character encoding and getInputStream()



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?

regards
Martin

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

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 © 2011 Apple Inc. All rights reserved.