Mysqlで作ったテーブルにUTF-8の文字を突っ込むとincorrect string value

技術関係

MysqlUTF-8の文字を突っ込むと以下の様なエラーで弾かれる
incorrect string value

一応、テーブルもUTF-8、突っ込む文字もUTF-8のはずだけど、受け入れてくれない
どうも特定の文字がはじかれるらしいというので調べてみると、MysqlのUTF-8は3バイトで表される範囲歯科対応していない様子

MySQL’s utf8 permits only the unicode characters that can be represented with 3 bytes in UTF-8. Here you have a character that needs 4 bytes: \xF0\x90\x8D\x83 (U+10343 GOTHIC LETTER SAUIL).

If you have MySQL 5.5 or later you can change the column encoding from utf8 to utf8mb4. This encoding allows storage of characters that occupy 4 bytes in UTF-8.

"Incorrect string value" when trying to insert UTF-8 into MySQL via JDBC?
This is how my connection is set: Connection conn = DriverManager.getConnection(url + dbName + "?useUnicode=true&charact...

じゃぁ、どうすればよいのかというとい、以下の様な話しらしい。

「UTF-8で4バイト」の文字を扱おうと思ったら、MySQL 5.5.3以降を使い、さらに”utf8mb4″を指定せよ、という冗談のような本当の話。

http://d.hatena.nh.jp/hhelibex/20120110/1326179698

ちなみに、今回突っ込もうとして失敗した文字はこんなの。なんて読むんだ
http://www.charbash.com/28a1e-unicode-invalid-character

タイトルとURLをコピーしました