PHP:在字符串操作中处理引号、转义等
我正在制作一个具有复杂字符串操作的特定类。
东西与 '
和 "
配合得很好。但是其中一个文本有一些奇怪的引号,角度如下:”
和 “
在我的代码中,显示为 -
而不是实际的引号,这破坏了我的代码,因为它有多个字符,
有人可以解释一下为什么会这样 。正在发生,你如何解决它?
I am making a certain class with complicated string manipulations.
Stuff works well with '
and "
. However one of the texts had some weird quotes at an angle like this: ”
and “
and in my code, the appear as â€
rather than actual quotes. That breakes my code, since its multiple characters, where it shouldn't have been.
Can somebody please explain why this is happening, and how do you work it around?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 utf-8 编码或替换所有不合适的字符。
这些引号虽然没有特殊含义,您可以忽略它们。
正如在评论中发现的那样,问题出在使用 substr 而不是 mb_substr() 。所以,有了后者,问题就解决了。
either use utf-8 encoding or replace all non-fitting characters.
these quotes has no spechial meaning though, you can ignore them.
as it was discovered in the comments, the problem was in using substr instead of mb_substr(). So, with the latter the problem solved.
我很确定这可以通过在标头中添加
来解决。这是因为无法读取“.或者你可以将其更改为正常”
Im pretty sure this can be solved by adding
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
in the header. This is caused because it can't read the “. Or you could just change it to normal "