• Post Reply Bookmark Topic Watch Topic
  • New Topic

Character Encoding Problem

 
Dave Babbitt
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys!

For some reason, if I type in this (to, say, the lastName field):

(English) ÀÂÄÅÆÇÉÈÊËÎÏÓÔÖŒÛÜ

request.getParameterValues("lastName") looks like this:

(English) Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?ÏÃ?Ã?Ã?Å?Ã?Ã?

This causes the database and the validation feedback to get polluted with this gibberish. I got stuff like this in the jsp:

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8" %>

and this in the head tag:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

EDIT: I ended up doing a Struts Filter and simplifying the email addresses to work around this problem (that only showed up when I was in debug, probably due to something in the 3rd party ORM).

 
Surya Kant
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you check your application server's encoding.I mean if it is tomcat you can specify in connector element
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You also need to take the character encoding of the storage/output/display in attention! If you for example did a system.out.println of that value, then the output source (logfile, IDE console, etc) should also use the right charset. If you for example stored it in a database and retrieved it again for display, then the associated database table should also use the right charset.

 
Dave Babbitt
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:You also need to take the character encoding of the storage/output/display in attention! If you for example did a system.out.println of that value, then the output source (logfile, IDE console, etc) should also use the right charset. If you for example stored it in a database and retrieved it again for display, then the associated database table should also use the right charset.


That would explain why this only happens in debug (I discovered later).
 
Dave Babbitt
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surya Kant wrote:did you check your application server's encoding.I mean if it is tomcat you can specify in connector element


I ended up adding a J2EE filter to change the response encoding. But I still get gibberish in the text-only fields in my email. There, I had to switch from using the "Inscrutable Name" <email@address.com> format to just using email@address.com format.
 
Leinad Jan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try to encode and decode in Javascript ? Usualy I don't care if the database store encoded strings. What is more important is the way it appears to the client.

Look at the following code, you can use that ! Credits to webtoolkit.info

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!