MySQL输出十六进制字符串为UTF-8

时间:2011-05-02 19:36:47

标签: mysql string utf-8 character-encoding hex

这适用于UTF8

create temporary table test (x char(1) not null) charset=utf8;
insert into test select x'c3a9';
select hex(x), x from test;
drop table test;

输出

+--------+---+
| hex(x) | x |
+--------+---+
| C3A9   | é | 
+--------+---+

但是这使用的是默认字符集,而不是utf8

SELECT x'c3a9';

如何更改上述单行以输出UTF-8 é而不是é

1 个答案:

答案 0 :(得分:4)

SELECT CONVERT(x'c3a9' USING utf8)

应该有效。请参阅11.10. Cast Functions and Operator

相关问题