railsにてTwitterAPIを叩いた結果をMYSQLにインサートしようとすると以下のエラー Mysql2::Error: Incorrect string value 結局のところ文字コードの問題なのだが絵文字をUTF8の拡張文字コードで返してくる為にMYSQLのチェックで引っかかりインサートできない様子 解決案としてMYSQLもキャラクターコードを「UTF8MB4」にすれば解決すると書いてあるが MYSQLのバージョンが5.5.3以上でないと対応できない。(現バージョン5.1) http://blog.k11i.biz/2012/11/utf-8-mysql-jdbc.html 仕方ないので4バイト文字は削除する事にした。 input.each_char.select{|c| c.bytes.count < 4 }.join('') http://stackoverflow.com