将 BLOB 转换为带有外来字符的 TEXT

发布于 2024-09-13 10:56:56 字数 232 浏览 3 评论 0原文

我有一个包含 HTML 的 blob。其中一些 HTML 包含外来字符(即:æ、ø 等)。我想将 BLOB 转换为 TEXT。我在我的表中使用 latin1 ,并且无法更改它。据我所知,如果我将外来字符存储在 TEXT 中,它会被转换为 ASCII 之类的东西。但如果你将它存储在 BLOB 中,则不会,它仍然是外来字符。

那么,如何将此 BLOB 数据转换为 TEXT,并将 BLOBL 数据转换为特殊字符的 ASCII 类似版本?

I have a blob which holds HTML in it. Some of this HTML has foreign characters (ie: æ, ø, etc). I want to convert the BLOB into TEXT. I am using latin1 for my tables and changing this is not an option. From what I can tell, if if I store the foreign characters in TEXT, it is converted into something like ASCII. But if you store it in BLOB, it doesn't, it stays as the foreign character.

So, how can I convert this BLOB data into TEXT adn convert the BLOBL data into the ASCII like versions for the special characters?

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

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

发布评论

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

评论(1

少跟Wǒ拽 2024-09-20 10:56:56

好吧,您的 blob 保存二进制数据...因此,如果其中包含文本 (HTML),则该文本必须以某种方式进行编码。它是什么编码?

您需要解码文本,然后让 mysql 将其重新编码为 Latin-1。这将保留一些非 ASCII 字符...但是有很多字符不属于 Latin-1。您根本无法用 Latin-1 正确表示这些内容。如果无法更改该选项,那么准确地将所有 Unicode 字符存储为文本也不是一个选项。

Well, your blob holds binary data... so if it's got text (HTML) in it, that text must have been encoded somehow. What encoding is it in?

You'll need to decode the text and then let mysql re-encode it as Latin-1. That will preserve some non-ASCII characters... but there are plenty of characters which aren't part of Latin-1. You simply won't be able to represent those correctly in Latin-1. If changing that is not an option, then accurately storing all Unicode characters as text isn't an option either.

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