C
cndc
Hi,
I have a textfile created on a Macintosh and its encoding is
MacRoman. Unfortunately, I'm having difficulty working with this
encoding. As a test case, I wrote this simple class that should read
in the MacRoman file and produce an ISO8859-1 file:
import java.io.*;
import java.nio.charset.*;
class Cheesy {
public static void main(String[] args) {
int i;
for(i = 0; i < args.length ; i++) {
try {
InputStreamReader r = new InputStreamReader(new FileInputStream(args), "MacRoman");
OutputStreamWriter o = new OutputStreamWriter(System.out, "8859_1");
int c;
while( (c = r.read() ) != -1) {
o.write(c);
}
} catch(IOException e) {
System.err.println(e.toString());
}
}
}
}
Sadly, however, many of the weird characters in MacRoman continue to
be converted to question marks as opposed to their normal character.
Am I doing something wrong?
Thank you,
Elizabeth
I have a textfile created on a Macintosh and its encoding is
MacRoman. Unfortunately, I'm having difficulty working with this
encoding. As a test case, I wrote this simple class that should read
in the MacRoman file and produce an ISO8859-1 file:
import java.io.*;
import java.nio.charset.*;
class Cheesy {
public static void main(String[] args) {
int i;
for(i = 0; i < args.length ; i++) {
try {
InputStreamReader r = new InputStreamReader(new FileInputStream(args), "MacRoman");
OutputStreamWriter o = new OutputStreamWriter(System.out, "8859_1");
int c;
while( (c = r.read() ) != -1) {
o.write(c);
}
} catch(IOException e) {
System.err.println(e.toString());
}
}
}
}
Sadly, however, many of the weird characters in MacRoman continue to
be converted to question marks as opposed to their normal character.
Am I doing something wrong?
Thank you,
Elizabeth