Hi Tomas,
The more robust databases, like DB2, allow you to set the character
encoding on a per table or even per column basis. In this case, the
transformation is done for you by the JDBC driver and the database engine
from the platform default ( and internal Unicode in Java. ) I don't know
offhand how/if MySQL handles this.
There's not a function exactly like you describe, but it really isn't
necessary, again because Java is internally in Unicode -- it has already
handled the translation from the platform default to Unicode for you. To
get the String from Unicode to ISO8859-2 and other supported encodings, use:
String(byte[] bytes, String enc) or
String(byte[] bytes, int offset, int length, String enc)
Note that this requires i18n.jar for the encoding you want. There was a
recent post about this with code at jGuru. See:
How do I convert a String from Unicode to another encoding and vice versa?
http://www.jguru.com/jguru/faq/view.jsp?EID=137049
There are several other entries dealing with encoding as well. See:
http://www.jguru.com/faq/I18N
Joe Sam
Joe Sam Shirah
Autumn Software - Consulting/Development/Outsourcing
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International? http://www.jguru.com/faq/I18N
Qué Java400? - Coming soon to a FAQ near you...
----- Original Message -----
From: "Tomas Zeman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 30, 2000 4:29 AM
Subject: Character encoding in Java
> Hi all,
> I have a servlet, by which you can insert data into the databaze (Mysql on
> Linux).
> I want to have all data in the databaze in ISO8859-2 charset (Czech
> republic), so my servlet needs to recode them from Cp1250, if someone will
> use my servlet on windows platform.
>
> Does anyone have a class, which can do this ? It could be some function
like
> String return_string = convertfromCp1250("string to convert");
>
> I looked at Locale and Character class, but it didn't worked.
>
> Thanks a lot
> Tomas Zeman
> www : http://www.triky.cz
> e-mail : [EMAIL PROTECTED]
>
>
___________________________________________________________________________
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