• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Chinese / English encoding problem

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hiya,
I have a problem POSTing xml data that contains English and Chinese characters - the Chinese characters are not received correctly (eg, when I send "name=你好嗎", it is received as "name=ä½ å¥½å").

Any ideas how I can solve, without messing up the English content?

Thanks,
James
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My standard answer is to point you at this good explanation of what is happening. Other than that, can you explain a bit more about how you are sending this data?
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply, Paul. The link hasn't really helped.

My code is:

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like I'm barking up the wrong tree.

The problem seems to be to do with a preceeding HTML form that submits its data to the servlet.

At the servlet, request.getCharacterEncoding() returns null.
If I add request.setCharacterEncoding("UTF-8") at the servlet, the problem seems to be fixed.

However, how do I fix my HTML form so that the character encoding info is correctly sent to the servlet (i.e., so I don't have to use request.setCharacterEncoding("UTF-8") at the servlet any more)??

Thanks in advance,
James
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The above fix worked on Glassfish, but not on Tomcat.

Tomcat solution is well described at http://wiki.apache.org/tomcat/FAQ/CharacterEncoding for anyone else with similar problem.
 
a wee bit from the empire
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic