Code: Select all
// Byte at $pos is either a leading byte or a missplaced trailing byte
if ($utf_len = $utf_len_mask[$c_mask])
{
Code: Select all
if( $utf_len>= 4 ) { // Strip for MySQL < 5.3.3
$pos+= $utf_len;
$tmp_pos= $pos;
continue;
}
Code: Select all
if (!in_array('STRICT_TRANS_TABLES', $modes))
{
$modes[] = 'STRICT_TRANS_TABLES';
}
Noxwizard wrote:if you disable the strict_trans_table mode, that will make the error go away, but it's probably just going to truncate the value which doesn't solve the problem either. If you really want to use those characters, you're going to have to use a database that fully supports UTF-8.
So you're only saying to MySQL "I don't care for errors when inserting something". Not having strict mode will result in the following: your text will be inserted from the first character up to the first invalid one (excluding that one, of course), discarding all characters after that invalid one. So if you have a text of 100 characters and the first one is already invalid (which is also considered invalid because of needing 4 bytes or more for UTF-8) then your posting will show up blank, since all the 99 other characters are simply not processed at all.Strict mode controls how MySQL handles input values that are invalid or missing
Note that prior to 5.5 only UCS-2 and UTF-8 are supported. If you have 5.5 or above you could at least use UTF8mb4 to have 4 byte characters stored.MySQL 5.5 supports these Unicode character sets:
- ucs2, the UCS-2 encoding of the Unicode character set using 16 bits per character
- utf16, the UTF-16 encoding for the Unicode character set; like ucs2 but with an extension for supplementary characters
- utf32, the UTF-32 encoding for the Unicode character set using 32 bits per character
- utf8, a UTF-8 encoding of the Unicode character set using one to three bytes per character
- utf8mb4, a UTF-8 encoding of the Unicode character set using one to four bytes per character