Post by carlitoAny java code out there to do a similar job as the one iconv does ?
iconv -f UTF-8 -t ISO-8859-1 -o output.csv input.csv
Thanks a lot for your help.
The Java String class will do this.
String s = new String( bytes, "UTF-8" );
where "bytes" is a byte[] of the raw UTF-8 codepoints. Convert the
variable s to ISO-8859 with
byte[] winCode = s.getBytes( "ISO-8859-1" );
"winCode" now contains Latin1 codepoints. You may have to check those
exact charset names, I didn't compile those lines.
<http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html>
Andrew's suggestion to use InputStreamReader/OuputStreamWriter seems
good too, if you are dealing with streams.
InputStreamReader in = new InputStreamReader( is, "UTF-8" );
will read a UTF-8 formatted InputStream "is" to Java's own internal
String format. OutputStreamWriter is similar.
Java's *internal* format is always the same. Java doesn't deal with
other codepoints directly, just as arrays of bytes (i.e., arrays of
data). You'll always have to go to Java's internal format first, then
to whichever output you want, asfaik.