Try using the method I have included herewith to encode the String and
then display the encoded String in the browser.
//---------------------------------------------------------
public String encodeString(String convertee, String charset ){
if(( convertee != null ) && ( encoding != null )){
try {
convertee = new String(convertee.getBytes(), charset);
} catch(UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return convertee;
}
//----------------------------------------------------------------
But I think it would be a pain in the neck to encode the data to display
every time you get out of the database. If your database supports storing
data in UTF-8 format, you should be able to encode the data when it goes
into the database( in servlets environment, you can write a wrapper method
around request.getParameter(param) which will encode the String for you ).
I would say I am still not very confident about the nitty-gritty knowledge
of how things work in the background. It would be nice if you don't need
to encode the data before you insert into the database ( as the String I
get from Java is in Unicode format and the browser should just be able to
encode and display the data appropriately using the charset supplied
from the header called "content" eg.
<meta http-equiv="Content-Type" content="text/html;charset=euc-kr"> for
Korean.
Thats my 2 cents.
Thanks
Pradeep
Pradeep Paudyal
Software Engineer,
Bricsnet US
Ph: 603 559 2505
On Fri, 12 Jan 2001, abdul aleem wrote:
> Date: Fri, 12 Jan 2001 04:45:07 -0800
> From: abdul aleem <[EMAIL PROTECTED]>
> Reply-To: A mailing list for discussion about Sun Microsystem's Java
> Servlet API Technology. <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Java unicode problem
>
> Hi,
> can some body help me out retriving a unicode
> value from the database and display it on the
> browser..
>
> i need to display chinese font on the browser
> right now i am reading a .ucs file and storing it to
> the database (DB2)
>
> i have problem in displaying it on the browser
> if i get the resultSet and embed in a HTML coding
> with meta tag set to display chinese charset
> it still display the unicode number and not the
> chinese font.
>
> Please suggest me wether i have to encode and decode
> before and after reading from the database..
> if so how to do the encoding and decoding too..
>
> Thanks in advance,
> Regards,
> Aleem
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Photos - Share your holiday photos online!
> http://photos.yahoo.com/
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html