(mysql.info) charset-convert
Info Catalog
(mysql.info) charset-result
(mysql.info) charset-operations
(mysql.info) charset-show
10.6.2 `CONVERT()' and `CAST()'
-------------------------------
`CONVERT()' provides a way to convert data between different character
sets. The syntax is:
CONVERT(EXPR USING TRANSCODING_NAME)
In MySQL, transcoding names are the same as the corresponding character
set names.
Examples:
SELECT CONVERT(_latin1'Mu"ller' USING utf8);
INSERT INTO utf8table (utf8column)
SELECT CONVERT(latin1field USING utf8) FROM latin1table;
`CONVERT(... USING ...)' is implemented according to the standard SQL
specification.
You may also use `CAST()' to convert a string to a different character
set. The syntax is:
CAST(CHARACTER_STRING AS CHARACTER_DATA_TYPE CHARACTER SET CHARSET_NAME)
Example:
SELECT CAST(_latin1'test' AS CHAR CHARACTER SET utf8);
If you use `CAST()' without specifying `CHARACTER SET', the resulting
character set and collation are defined by the
`character_set_connection' and `collation_connection' system variables.
If you use `CAST()' with `CHARACTER SET X', the resulting character set
and collation are `X' and the default collation of `X'.
You may not use a `COLLATE' clause inside a `CAST()', but you may use
it outside. That is, `CAST(... COLLATE ...)' is illegal, but `CAST(...)
COLLATE ...' is legal.
Example:
SELECT CAST(_latin1'test' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin;
Info Catalog
(mysql.info) charset-result
(mysql.info) charset-operations
(mysql.info) charset-show
automatically generated byinfo2html