gpt4 book ai didi

php - 从mysql解码utf-8字符

转载 作者:行者123 更新时间:2023-11-29 22:35:40 25 4
gpt4 key购买 nike

我面临一些奇怪的问题。我的 mysql 表中存储了以下字符串:

The horses had been brought in from the hills and were tethered next to a pile of drying dung. All around were snowcapped peaks and on one side lay a shimmering lake of glacial blue water. The Kyrgyz men were deciding who would ride which horse. Kanybek looked at me, the only man left in our riding party, which had somehow slimmed down from 10 to three at the sight of the stallions. I'd heard about Kanybek, the best ulak player in the area (that’s polo played with a dead headless goat, the same as the Afghan bushkazi).

Kanybek was a man who could pluck a 10 som note from the ground at a full gallop, a man who could mount a steed with a back somersault. He had been born in the shadow of a horse, ridden before he could walk and drunk mare’s milk ever since. I had serious doubts whether Kanybek could begin to comprehend how crap I was at riding horses.

“This one is for you,” he said, his weathered face splitting into a champion grin. “It is the fastest.”

当我将其从数据库检索到 php 时,它开始显示 而不是 '。按照我在 php 中检索它后所看到的内容。

The horses had been brought in from the hills and were tethered next to a pile of drying dung. All around were snowcapped peaks and on one side lay a shimmering lake of glacial blue water. The Kyrgyz men were deciding who would ride which horse. Kanybek looked at me, the only man left in our riding party, which had somehow slimmed down from 10 to three at the sight of the stallions. I'd heard about Kanybek, the best ulak player in the area (that�s polo played with a dead headless goat, the same as the Afghan bushkazi).

Kanybek was a man who could pluck a 10 som note from the ground at a full gallop, a man who could mount a steed with a back somersault. He had been born in the shadow of a horse, ridden before he could walk and drunk mare�s milk ever since. I had serious doubts whether Kanybek could begin to comprehend how crap I was at riding horses.

�This one is for you,� he said, his weathered face splitting into a champion grin. �It is the fastest.�

我尝试了很多 php 函数和很多组合,但最后我什么也没得到。

mb_convert_encoding(),iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $description),html实体等..

这些都返回空字符串。

我已经设置

   <meta charset="utf-8">

我正在使用 PDO 检索数据,我的数据库集合是 utf-8。

基本上,我正在阅读第三方 rss feed,并通过 cron 将它们存储到我的数据库中。

非常感谢您的帮助。

最佳答案

这是一个相当广泛的问题。您需要确保从表单提交、PHP mysql/mysqli 实例到数据库本身的所有内容都设置为正确使用 UTF8。请参阅UTF-8 all the way through .

您可能需要添加 <meta charset="UTF-8"><head> HTML 文档的名称,让 Web 浏览器知道您正在直接显示 UTF8 内容。这将使您的网络浏览器能够显示 UTF8 内容(如果可以)。

如果这没有帮助,请尝试使用 utf8_decode() .

关于php - 从mysql解码utf-8字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29559948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com