tags:

views:

346

answers:

1

I am currently developing a Java Struts application and i been wondering how is it possible to display chinese characters in AJAX and also when generating excel file by servlet response.

Anyone can share any pointers?

+1  A: 

As long as you use UTF8 for your character encoding, I think you should be fine. If UTF8 is not an option, and you're going to display only Chinese, you can even try one of the Chinese specific character encodings.

I'll try and get you more details, but at the very least, to set the character encoding, you'll have to do:

response.setCharacterEncoding("UTF-8");

or

response.setContentType("text/plain; charset=UTF-8");

Refer to the Java EE Specs (http://java.sun.com/j2ee/1.4/docs/api/index.html) for what these mean exactly.

Jack Leow
UTF-8 probably won't work for the Excel bit though.