Wednesday, June 24, 2009

Insert Double Byte Characters to Database

We cannot insert the double byte characters (eg: Chinese, Russian, Japanese etc) into a database directly. This is not possible even if we configure the database to Unicode encoding.

All the editors we use to run the sql does not recognize the double byte characters. They support only ASCI characters. So if we try to run a query which contains a double byte character, say Chinese, then the editor will replace the characters with question marks (???) means it does not recognize the symbol.

For Eg: if we copy the following query to an sql editor,

insert into () values ('支付宝');

then the editor will convert it as

insert into () values ('???');


There is a solution for this issue.

We can use the sql function compose() and we can pass the unicode of the characters to the function.

Eg: insert into () values (compose(unistr('\652F\4ED8\5B9D')));

This will insert the double character to the db.

The characters can be converted to the unicode using the following site
http://rishida.net/scripts/uniview/conversion.php


.

No comments:

Post a Comment