I have got the Java String ôð¤ Ø$î1<¨ V¸dPžÐ ÀH@ˆàÀༀ@~€4` which I would like to write to a file with ANSI encoding.
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(output),"windows-1252"));
try {
out.append(str);
} finally {
out.close();
}
Debugger says that str contains ôð¤ Ø$î1<¨ V¸dPÐ ÀH@àÀà¼@~4. As soon as I write it to the output file, the file only contains ?ÒÜ@4. So whats wrong with my method writing to the File?
Sorry for this weird strings – I am trying to rewrite a delphi 7 function in java. These strings are the only samples I have got.
If I run
it prints
so no characters are lost in translation.
If I change the encoding to “US-ASCII” I get the following output