Re: CHAR_LENGTH() returns incorrect value on Japanese UTF8 text
Posted by: Peter Gulutzan
Date: August 23, 2007 02:32PM

mysql> set names utf8;
Query OK, 0 rows affected (0.04 sec)

mysql> select version();
+-------------------+
| version() |
+-------------------+
| 5.1.22-beta-debug |
+-------------------+
1 row in set (0.12 sec)

mysql> CREATE TABLE multibyte
-> (
-> thing VARCHAR(20) CHARACTER SET utf8
-> );
Query OK, 0 rows affected (7.40 sec)

mysql>
mysql> INSERT INTO multibyte (thing) VALUES('human');
Query OK, 1 row affected (0.22 sec)

mysql> INSERT INTO multibyte (thing) VALUES('ははは'); #if you can't read this it's "hahaha" in hiragana
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> SELECT thing, CHAR_LENGTH(thing), LENGTH(thing) FROM multibyte;
+-----------+--------------------+---------------+
| thing | CHAR_LENGTH(thing) | LENGTH(thing) |
+-----------+--------------------+---------------+
| human | 5 | 5 |
| ははは | 3 | 9 |
+-----------+--------------------+---------------+
2 rows in set (0.24 sec)

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: CHAR_LENGTH() returns incorrect value on Japanese UTF8 text
2483
August 23, 2007 02:32PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.