On Apr 24, 1:44 am, Abyric <
killingd...@gmail.com> wrote:
> Could you then please explain why my characters are turning all
> gibberish when I import special characters?
>
I have very successfully used H2 database to store ,retrieve and
display Indian languages text in web applications.
If H2 can handle languages like Gujarati and Hindi properly using
UTF-8 encoding than there is no reason why any other languages like
( Chinese, Korean ) etc can not be stored or retrieved in H2.
The problem is that the JSP Engine ( Tomact / Resin
(
www.caucho.com ) ) should be configured to handles UTF-8 encoded
text properly.
To make UTF-8 character set as default in your JSP page put following
line at the top:
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
It is also sometimes necessary to put following meta-tags in HTML page
also
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Otherwise in Java, you will have to specify encoding every time you
construct a String from result set like this:
Suppose rslt is your JDBC ResultSet from which you are fetching a
table column text.
Than the code should be
String my_utf_string = new String( rstl.getString
("column_name").getBytes(), "UTF-8" )
In this case the row bytes are fetched from table column and from that
a new String is constructed using UTF-8 as the character encoding.
When you explicitly specify UTF-8 as default character set in JSP
page with directive @page pageEncoding="UTF-8", than the character
conversion is automatically handled for you by JSP engine.
Please also note that you must properly set character encoding in
HTML form elements like INPUT and TEXTAREA as well.
Hope this helps you
Thanks
Sharad Kelkar