Custom Search

[Top] [All Lists]

UTF8 from form to mySQL

Subject: UTF8 from form to mySQL
Date: Fri, 04 Feb 2011 15:45:03 -0500
Hi there,
So I'm sure there's someone out there who has met this problem and has found a solution, therefore, let me ask the source. We are dealing with an international web platform - many many languages. People submit forms in different languages and it all stored in a mySQL database. Basically, I'm having troubles getting UTF8 to work with said database. I have troubles at all levels - stripes and database.
Here's my set up:
    - mySQL 5.1
    - mysql-jdbc 5.1 (driver)
    - tables - utf8
    - LocalePicker is always forcing charset to UTF-8 in stripes
Here's the problem:
- User enters some characters into the form (chinese, russian, hebrew....)
    - ActionBean sticks it into the database and sends email.
    - Fields are declared as Strings and nothing is done to the values
    - When sticking to the database it will contain - ???? as values
    - The output from the database obviously doesn't work
- When printing submitted value on page from ${actionBean.field} it displays junk
I know that browsers send all forms to the servers in ISO-8859-1 
encoding. In the good old days, or with plain servlets, I would always 
have to convert submitted values to UTF-8 with the following: new 
String(rs.getString(1).getBytes("ISO-8859-1"), "UTF-8"); From then on 
the value is in UTF-8
In Stripes, I think that the values come to ActionBeans in ISO-8859-1 
since StringTypeConverter doesn't do anything. That's fine, I wrote my 
own converter for UTF using the logic from above. This solves the 
problem with printing submitted value on the page ${actionBean.field}; 
but if the value is still displayed in the form it is all grumbled as if 
it was ISO-8859-1 representation of UTF-8. That I don't understand.
As for storing UTF8 into mySQL - well, if someone can help me out it 
would be great since I can't get UTF8 string stored in the database 
without doing the UTF8 to ISO-8859-1 and back conversion while keeping 
tables at latin1 I would really appreciate it. The main question is Stripes.
I hope this whole rambling makes sense and someone has had this problem 
previously. Hopefully there was a solution.

Description: Vcard

The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
Stripes-users mailing list
[email protected]
<Prev in Thread] Current Thread [Next in Thread>
Current Sitemap | © 2012 planetjava | Contact | Privacy Policy