Hello Friends, How are you ? I am Sohil. I am here with a problem
I am creating a text editor that will store data in mySql database. I
want to get the data in text field. I am having "♥" character in
database.
Select * from bank_master;
+---------+-----------+
| Bank_Id | Bank_Name |
+---------+-----------+
| 3 | ♥ |
+---------+-----------+
I am not able to display this character in textbox. The text box is
showing a rectangle instead of that character.
textfield.setText(rs.getString("Bank_Name"));
But, when I am retriving the character from text box and display it on
the command prompt console it shows right character ie. "♥"
System.out.println(textfield.getText());
I am not able to get the problem here.
Sohil Surti
mikey - 28 Jan 2007 06:32 GMT
Hi Sohil,
your problem is that what you have in the database is a bitpattern that
can be interpreted differently. The interpretation of a bitpattern as a
string of characters is called 'encoding'. What you are seeing here is
that the DOS box uses an encoding with a name/number I can't remember
right now while the textfield probably uses an encoding named 'UTF8'.
'UTF8' is far superior to the encoding used by DOS if you plan on any
internationalization (google for UNICODE). So you should stick with that
and think about where the data in the DB came from. You'll probably
have to do some conversion.
Cheers
> Hello Friends, How are you ? I am Sohil. I am here with a problem
>
[quoted text clipped - 22 lines]
>
> Sohil Surti