Note that there are some explanatory texts on larger screens.

plurals
  1. POMysql2::Error: Incorrect string value for Turkish characters
    primarykey
    data
    text
    <p>In a Rails 4.0 app with Ruby 2.0, Turkish characters lead to the following ActiveRecord / MySQL error while trying to insert a record in the database. The problematic characters are for instance ğ and ş, but there is no problem with ü or Ç (which also seem to occur in latin charsets).</p> <pre><code>ActiveRecord::StatementInvalid (Mysql2::Error: Incorrect string value: '\xC4\x9Fu\xC5\x9F ...' for column ... </code></pre> <p>How do you prevent this error? The application and the database use <a href="http://en.wikipedia.org/wiki/UTF-8" rel="nofollow noreferrer">UTF-8</a> as standard encoding. "xC4\x9F" is UTF-8 encoding for "ğ", "\xC5\x9F" is UTF-8 for "ş". Both seem to be the problematic special characters. There is no problem with German (äöü) or French (áàâ) special characters. Contrary to <a href="http://en.wikipedia.org/wiki/ISO/IEC_8859-1" rel="nofollow noreferrer">ISO 8859-1</a> or ISO 8859-15 (only <a href="http://en.wikipedia.org/wiki/ISO/IEC_8859-9" rel="nofollow noreferrer">ISO 8859-9</a> supports all Turkish characters) it should be possible to store <a href="https://stackoverflow.com/questions/14680059/how-to-define-declare-utf-8-code-points-for-turkish-special-chars-non-ascii-to">Turkish characters in UTF-8</a>. </p> <p>The MySQL collection settings for the database are as follows. Would it be helpful to switch <code>collection_database</code> to a different value, such as <code>utf8_unicode_ci</code>? </p> <pre><code>mysql&gt; show variables like '%collation%'; +----------------------+-------------------+ | Variable_name | Value | +----------------------+-------------------+ | collation_connection | utf8_general_ci | | collation_database | latin1_swedish_ci | | collation_server | latin1_swedish_ci | +----------------------+-------------------+ </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload