MySQL 不想存储 unicode 字符

发布于 2024-08-29 20:34:41 字数 29 浏览 5 评论 0 原文

为什么MySQL不存储unicode字符

Why won't MySQL store the unicode character ????? Yes, it is a rare hieroglyph, you wouldn't see it in the browser.
UTF16 is U+2B5EE

Warning: #1366 Incorrect string value: '\xF0\xAB\x97\xAE' for column 'ch' at row 1

Is it possible to store this character in MySQL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

芯好空 2024-09-05 20:34:41

MySQL 仅支持基本多语言平面中的字符(0x0000 - 0xFFFF)。

如果这架飞机你的角色就出局了。

尝试存储同义词:)

更新:

MySQL 5.5.3 及以上版本(尚未正式发布)如果您使用 UTF8MB4 编码

MySQL only supports characters from the basic multilingual plane (0x0000 - 0xFFFF).

Your character is out if this plane.

Try storing a synonym instead :)

Update:

MySQL 5.5.3 and on (which has not gone GA yet) does support supplementary characters if you use UTF8MB4 encoding.

好久不见√ 2024-09-05 20:34:41

第一:你的陈述

UTF16 是 U+2B5EE

稍有错误。 U+2B5EE 是 Unicode codepoint 的表示法,只是一个整数 - 一个抽象代码 - 而 UTF16 是一种字符集编码(可能的 Unicode 编码之一,就像 UTF -8)。

现在,假设您指的是代码点,U+2B5EE 位于 BMP 之外(第一个 64K unicode 代码点),并且 mysql 似乎有 对它们的支持很少或根本不支持。所以我怀疑你运气不好。

First: your statement

UTF16 is U+2B5EE

is slightly wrong. U+2B5EE is the notation for a Unicode codepoint, just a integer number- an abstract code- while UTF16 is a charset encoding (one of possible Unicode encodings, as is UTF-8).

Now, assuming that you mean the codepoint, U+2B5EE is outside the BMP (first 64K unicode codepoints), and it seems mysql have little or no support for them. So I suspect you are out of luck.

夜无邪 2024-09-05 20:34:41

自从这个问题发布后,MySQL 5.5.3 就发布了,它支持 utf8mb4 编码,提供完整的 Unicode 支持。切换到此字符集而不是 utf8 可以解决您的问题。

我最近写了关于如何从 MySQL 切换的详细指南 utf8utf8mb4。如果您按照那里的步骤操作,一切都应该正常工作。以下是该过程中每个步骤的直接链接:

我怀疑您的问题可以按照第5步解决。希望这会有所帮助!

Since this question was posted, MySQL 5.5.3 was released which supports the utf8mb4 encoding which offers full Unicode support. Switching to this charset instead of utf8 would fix your problem.

I’ve recently written a detailed guide on how to switch from MySQL’s utf8 to utf8mb4. If you follow the steps there, everything should work correctly. Here are direct links to each individual step in the process:

I suspect that your problem can be solved by following step 5. Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文