简体   繁体   English

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

[英]MySQL output hex string as UTF-8

This works UTF8这适用于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;

outputs输出

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

But this uses the default charset which is not utf8但这使用不是 utf8 的默认字符集

SELECT x'c3a9';

How can I change the above one-liner to output UTF-8 é instead of é ?如何将上述单行代码更改为 output UTF-8 é而不是é

SELECT CONVERT(x'c3a9' USING utf8)

should work.应该管用。 See 11.10.11.10。 Cast Functions and Operator .强制转换函数和运算符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM