•If the server sends the error message to a client program, the server converts it from UTF-8 to the character set specified by the character_set_results  system variable. If character_set_results  has a value of NULL  or binary , no conversion occurs. No conversion occurs if the variable value is utf8mb3  or utf8mb4 , either, because those character sets have a repertoire that includes all UTF-8 characters used in message construction. 

If characters cannot be represented in character_set_results , some encoding may occur during the conversion. The encoding uses Unicode code point values: 

•Characters in the Basic Multilingual Plane (BMP) range ( 0x0000  to 0xFFFF ) are written using \ nnnn notation. 

•Characters outside the BMP range ( 0x10000  to 0x10FFFF ) are written using \+ nnnnnn  notation. 

Clients can set character_set_results  to control the character set in which they receive error messages. The variable can be set directly, or indirectly by means such as SET NAMES . For more information about character_set_results , see Section 10.4, “Connection Character Sets and Collations” . 

## 10.7 Column Character Set Conversion 

To convert a binary or nonbinary string column to use a particular character set, use ALTER TABLE . For successful conversion to occur, one of the following conditions must apply: 

•If the column has a binary data type ( BINARY , VARBINARY , BLOB ), all the values that it contains must be encoded using a single character set (the character set you’re converting the column to). If you use a binary column to store information in multiple character sets, MySQL has no way to know which values use which character set and cannot convert the data properly. 

•If the column has a nonbinary data type ( CHAR , VARCHAR , TEXT ), its contents should be encoded in the column character set, not some other character set. If the contents are encoded in a different character set, you can convert the column to use a binary data type first, and then to a nonbinary column with the desired character set. 

Suppose that a table t  has a binary column named col1  defined as VARBINARY(50) . Assuming that the information in the column is encoded using a single character set, you can convert it to a nonbinary column that has that character set. For example, if col1  contains binary data representing characters in the greek  character set, you can convert it as follows: 

ALTER TABLE t MODIFY col1 VARCHAR(50) CHARACTER SET greek; 

If your original column has a type of BINARY(50) , you could convert it to CHAR(50) , but the resulting values are padded with 0x00  bytes at the end, which may be undesirable. To remove these bytes, use the TRIM()  function: 

UPDATE t SET col1 = TRIM(TRAILING 0x00 FROM col1); 

Suppose that table t  has a nonbinary column named col1  defined as CHAR(50) CHARACTER SET latin1  but you want to convert it to use utf8  so that you can store values from many languages. The following statement accomplishes this: 

ALTER TABLE t MODIFY col1 CHAR(50) CHARACTER SET utf8; 

Conversion may be lossy if the column contains characters that are not in both character sets. 

A special case occurs if you have old tables from before MySQL 4.1 where a nonbinary column contains values that actually are encoded in a character set different from the server’s default character set. For example, an application might have stored sjis  values in a column, even though MySQL’s default 

