Home > MySQLと文字コード

MySQLと文字コード

  • March 27, 2008 11:06 AM

MySQL :: MySQL 5.1 Reference Manual :: 9.1.7.2 CONVERT() and CAST()

〜が~に文字化けするのは直ったか | MySQL日本語の旅 | OpenSource Web
Convert使う例

CAST()でもキャラクタセットの変換ができる | MySQL日本語の旅 | OpenSource Web
Castの紹介

メモ:

[(none)]> show variables like '%chara%'; +--------------------------+---------------------------------------------------------------+ | Variable_name | Value | +--------------------------+---------------------------------------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/local/mysql-5.1.22-rc-osx10.4-i686/share/mysql/charsets/ | +--------------------------+---------------------------------------------------------------+ 8 rows in set (0.13 sec)
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.22-rc-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

[(none)]> select hex(convert(_utf8"あ" using utf8));
+-------------------------------------+
| hex(convert(_utf8"あ" using utf8)) |
+-------------------------------------+
| E38182 |
+-------------------------------------+
1 row in set (0.17 sec)

[(none)]> select hex(convert(_utf8"あ" using cp932));
+--------------------------------------+
| hex(convert(_utf8"あ" using cp932)) |
+--------------------------------------+
| 82A0 |
+--------------------------------------+
1 row in set (0.01 sec)

[(none)]> select hex(convert(_utf8"あ" using sjis));
+-------------------------------------+
| hex(convert(_utf8"あ" using sjis)) |
+-------------------------------------+
| 82A0 |
+-------------------------------------+
1 row in set (0.10 sec)

[(none)]> select hex(convert(_utf8"あ" using eucjpms));
+----------------------------------------+
| hex(convert(_utf8"あ" using eucjpms)) |
+----------------------------------------+
| A4A2 |
+----------------------------------------+
1 row in set (0.02 sec)

[(none)]> select hex(convert(_utf8"あ" using ujis));
+-------------------------------------+
| hex(convert(_utf8"あ" using ujis)) |
+-------------------------------------+
| A4A2 |
+-------------------------------------+
1 row in set (0.00 sec)

[(none)]> select hex(convert(_utf8"あ" using latin1));
+---------------------------------------+
| hex(convert(_utf8"あ" using latin1)) |
+---------------------------------------+
| 3F |
+---------------------------------------+
1 row in set (0.00 sec)

[(none)]>


[(none)]> select convert(_utf8 0xE69C88 using utf8);
+-------------------------------------+
| convert(_utf8 0xE69C88 using utf8) |
+-------------------------------------+
| 月 |
+-------------------------------------+
1 row in set (0.00 sec)

Home > MySQLと文字コード

Search
Feeds

Return to page top