显示某种撇号(当前显示为菱形) [英] Displaying some sort of apostrophe (Currently shows as diamond)

查看:138
本文介绍了显示某种撇号(当前显示为菱形)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我数据库中的某些行包含各种撇号,当用PHP显示时,它们会转换为菱形,中间带有问号。例如,如果复制正确: Jim O'Brien队长

Some rows in my database contain an apostrophe of sorts, that, when displayed with PHP, are converted to diamonds with a question mark in the center. Example, if it copies correctly: Captain Jim O’Brien

这些撇号很可能是通过TinyMCE插入的,用户可能是从Word或Mac计算机上进行复制和粘贴的。

These "apostrophes" were inserted most likely via TinyMCE, where the user was copying and pasting from Word, or something from a Mac computer perhaps.

如何显示这些撇号?当我在PHPMyAdmin中查看该行时,将显示撇号(没有菱形),因此显然有一种方法。

How can I display these "apostrophes"? When I view the row in PHPMyAdmin, the apostrophes are displayed (no diamond), so there is obviously a way.

我的字符编码设置为UTF-8,并且我试过 htmlspecialchars($ string) htmlentities($ string),没有运气。

My character encoding is set to UTF-8, and I've tried htmlspecialchars($string) and htmlentities($string), with no luck.

推荐答案

字符在不同的位置编码。

Characters are encoded in different places.

MySQL具有特殊的字符编码。默认情况下,它不是 UTF-8,而是latin1。

MySQL has a particular character encoding. By default, it is not UTF-8 but rather latin1.

使用PHP生成的HTML文档还指定了特定的字符编码。最后,HTML文档中的实际字节实际上采用了特定的字符编码,如果您不注意,则可能与您为文档指定的字符编码不同。

The HTML document you generate using PHP also has a particular character encoding specified. Finally, the actual bytes in the HTML document factually assume a particular character encoding, which if you're not careful can be different than the character encoding you specify for the document.

确认第一步,将您的MySQL编码设置为UTF-8。请注意,MySQL可以具有针对数据库的默认字符编码,该字符编码可以按表甚至按列进行覆盖。

Verify that your MySQL encoding is set to UTF-8 as a first step. Note that MySQL can have the default character encoding for the database overridden on a per-table or even per-column basis.

您可能对此相关文章感兴趣对字符编码有更深入的了解

You may be interested in this related post to get a deeper understanding of character encoding

字符编码和’问题

更新

将数据放入MySQL数据库中第一名。也许那个东西没有使用UTF-8编码。

Something put the data into the MySQL database in the first place. Perhaps that "something" was not using UTF-8 encoding.

这篇关于显示某种撇号(当前显示为菱形)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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