We help IT Professionals succeed at work.

Chinese Character problem!!!

addychto asked
Dear Experts,

     When Chinese words are displayed in browser through jsp, everything is alright. However, when the words are saved into files or print out in the log file, also through jsp, they are displayed as ???. My application server is jrun. Do you face this problem? I am not sure where the problem comes from, jrun or programming code?
I have set the following in my code.


     response.setContentType("text/html; charset=Big5");

Watch Question

When you write to file, explicitly declare the encoding:

File f = new File("foo.bar");
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(f), "Big5");

// Write you file.
// To get the file:
File f = new File("foo.bar");
InputStreamReader isr = new InputStreamReadeer(new FileInputStream(f), "Big5");
This allows the JVM to keep the correct Unicode characters. My guess is that your way would have worked if you didn't specify Big5 in the content-type, but it would have created errors elsewhere.

This question is LOCKED with a Proposed Answer.  If it helps you, great, accept it and grade it to close.  If not, reject it and comment as to why or what else is needed.

Few additional experts will join this collaboration effort, once a question has been locked.  Just want to confirm this to you.  If more than one expert helps you, you can always split points or award additional help in a new question, within the same topic area.  If you need help from us, post a zero point question here, and include the link:


Community Support Moderator @ Experts Exchange
Force Accepted

Community Support Moderator @Experts Exchange

Explore More ContentExplore courses, solutions, and other research materials related to this topic.