Hello javaranchers, I'm now developing an web application that will use some chinese characters and those characters will be store in my database for use. I managed to convert the chinese words into unicode, but i need helps for convert them into html codes. Eg, from 0026002300320033003400380031003b to this format 容
Thanks in advance.
Regards, mirai chelean
The moon light is pouring down on my bedside<br />Like white frost spreading on the ground<br />I look up the bright round moon in the sky<br />And lower my head thinking of my dear hometown
Mirai Chelean
Greenhorn
Joined: Jun 27, 2005
Posts: 23
posted
0
Hello? Is there anybody can help me?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35237
7
posted
0
What kind of data is the following:
0026002300320033003400380031003b
Unicode characters are two-byte characters (for the most part), so I'm a bit confused by this long numeric sequence. How did you compute that? To display Unicode characters in a web page, nothing special needs to be done. Just include them in the page, and set the character set encoding according to your situation, e.g. <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> if your characters are UTF-8 encoded. Then they should be viewable by anybody that has an appropriate font installed.
Thanks for reply, that long numeric sequence is hex code for a single chinese character. Sorry for if i make you guys confusing because i'm yet not a java expert . The case is like this, i got raw codes in hex that i need to convert them into html codes format like this Maybe if you look into this chart you will more clear with what i mean. The long numeric is hx and i want to convert them into Html, eg. let say i want to convert 4C(Hx) to L ;(Html). Is there any way to do that? Because i want to insert the data into my database with the html format (x .
Thanks in advance.
Mirai_Chelean
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35237
7
posted
0
I'm still unclear on what kind of data that long string is. If it's hex, it should take 4 characters to describe a Chinese character in Unicode. So I don't think that's Unicode what you have there. Given that, I can't guess how it might be translated to HTML codes. Is it a requirement to store HTML codes in the DB? Because, as stated above, web pages can be displayed from the actual Unicode characters.
Mirai Chelean
Greenhorn
Joined: Jun 27, 2005
Posts: 23
posted
0
Hi ulf,
Thanks again for the answer, as i mentioned before i'm certainly no java expert. There might be some places i've make mistake, but yea thats the one of the requirements that those data need to be store in database as html codes. Maybe be if there is some other way, eg. from ascii code(Dec) to html code?
By the way, here is the code that how i get those strange hex. If there is mistake, please help me.
private String getHexCode(String text){ String hex,hexString=""; char chr; int ascii,length=text.length();
So the string posted above actually consists of 8 characters. But their values are all between 38 and 49, which are punctuation symbols and digits in Unicode; certainly not letters of any kind. That must be some kind of special encoding, not Unicode, so the built-in Unicode support in Java probably will not help you.