encoding, get ASCII as default encoding
Hi,
I'm using Linux (Red Hat 8), where I have installed Java .1.4. Now when I try to parse xml feed from request.inputStream im getting wrong encoding values.
Im storing all the xmlfeeds when i receive on seperate files, but when I get the encoding for the files I get ASCII. Doesn't java have UTF-8 as default encoding? Even thought I have explicitly told that the input is utf-8 (request.setEncoding ("utf-8")) it does not work.
Therefore im getting wrong values stored on the database (utf-8 tables).
Where is the default encoding ASCII come from ?
Can anyone please answer..
[622 byte] By [
thenaya] at [2007-10-2 12:50:50]

No, Java doesn't have UTF-8 as its default encoding. But that isn't the right question. The question is where do these "files" come from? If you're writing them with a Writer then you can control their charset yourself, with an OutputStreamWriter. It isn't clear to me why they exist at all, since your intent seems to be to update a database.
It's also possible that the database interface isn't set up correctly. But don't try to test request, processing, and database all at once. Test the parts separately.
thank you for the replay,
After your advise im now being more strict about encoding to utf-8. Im doing following:
1. setting request to utf-8 explicitly. request.setCaracterEncoding("utf"))
2. opening bufferedStreamReader with encoding parm.
with request.getInputStreamreader
String xmlString = null
String line;
BufferedReader reader = new BufferedReader(new InputStreamReader(
request.getInputStream(),"UTF-8"));
while ((line = reader.readLine()) != null) {
xmlString += line + "\r\n";
}
3. Then dump the string to a file to verify that i got the right encoding:
File f = new File ("out.xml");
FileOutputStream fos = null;
OutputStreamWriter out = null;
fos = new FileOutputStream(f);
out = new OutputStreamWriter(fos, "UTF-8");
Writer w = new BufferedWriter(out);
w.write(xmlString);
4. when i finally take upload on the out.xml file from Linux server to windows os, open the file i get non-ascii character to be ?. The copyright character get ?. Do i do anything wrong, or can it bee that im missing some lib for the redhad distribution?