MySQL中的Unicode(十六进制)字符文字 [英] Unicode (hexadecimal) character literals in MySQL

查看:848
本文介绍了MySQL中的Unicode(十六进制)字符文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在MySQL中指定Unicode字符文字?

Is there a way to specify Unicode character literals in MySQL?

我想用ASCII字符替换Unicode字符,如下所示:

I want to replace a Unicode character with an Ascii character, something like the following:

Update MyTbl Set MyFld = Replace(MyFld, "ẏ", "y")

但是我正在使用甚至更多字体中都看不到的更加晦涩的字符,因此我希望能够使用Unicode字符文字,例如

But I'm using even more obscure characters which are not available in most fonts, so I want to be able to use Unicode character literals, something like

Update MyTbl Set MyFld = Replace(MyFld, "\u1e8f", "y")

此SQL语句正在从PHP脚本中调用-第一种形式不仅不可读,而且实际上不起作用!

This SQL statement is being invoked from a PHP script - the first form is not only unreadable, but it doesn't actually work!

推荐答案

感谢您的建议,但我认为问题仍在系统中.

Thanks for your suggestions, but I think the problem was further back in the system.

要取消选择的级别很多,但据我所知,(至少在此服务器上)命令

There's a lot of levels to unpick, but as far as I can tell, (on this server at least) the command

set names utf8

使utf-8处理正常工作,而

makes the utf-8 handling work correctly, whereas

set character set utf8

没有.

在我的环境中,这些是使用PDO从PHP调用的,可能会有什么不同.

In my environment, these are being called from PHP using PDO, for what difference that may make.

还是谢谢!

这篇关于MySQL中的Unicode(十六进制)字符文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆