utf-8 (PHP, str_replace) 中是否有不同类型的双引号?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18735921/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Are there different types of double quotes in utf-8 (PHP, str_replace)?
提问by Urs
In PHP 5.3, am trying to replace double quotes in a string as such:
在 PHP 5.3 中,我试图像这样替换字符串中的双引号:
$bar = str_replace('"','\'',$foo);
But some quotes that are saved in the utf8-Database are not being replaced, although they look perfectly normal:
但是保存在 utf8-Database 中的一些引号并没有被替换,尽管它们看起来完全正常:
"Some text"
"Some text"
Are there different character types I have to search for? If so, which are they?
我必须搜索不同的字符类型吗?如果是,它们是哪些?
回答by Joni
There are many characters that look like quotation marks, most of them are used infrequently. The ones that are used more often are these three:
有很多看起来像引号的字符,其中大多数很少使用。比较常用的就是这三个:
" U+0022 QUOTATION MARK
“ U+201C LEFT DOUBLE QUOTATION MARK
” U+201D RIGHT DOUBLE QUOTATION MARK
Some rarer ones are FULLWIDTH QUOTATION MARK, the DITTO MARK, the DOUBLE PRIME, the DOUBLE PRIME QUOTATION MARK, and so on. The Unicode.org "confusables" tool finds 15 characters similar to "
.
一些比较少见的是 FULLWIDTH QUOTATION MARK、DITTO MARK、DOUBLE PRIME、DOUBLE PRIME QUOTATION MARK 等等。Unicode.org "confusables" 工具找到了15 个类似于"
.
Why don't you copy and paste the offending character here so we can identify it? Or you could use the HEX function to get the hexadecimal encoding of the character, that's another way of identifying it.
你为什么不在这里复制并粘贴有问题的字符,以便我们识别它?或者您可以使用 HEX 函数来获取字符的十六进制编码,这是识别它的另一种方式。
回答by Nagli
回答by S.Doe_Dude
Able to insert a quotation using "numerical HTML encoding of the Unicode character"
能够使用“Unicode 字符的数字 HTML 编码”插入引号
http://www.utf8-chartable.de/unicode-utf8-table.pl?unicodeinhtml=dec&htmlent=1
http://www.utf8-chartable.de/unicode-utf8-table.pl?unicodeinhtml=dec&htmlent=1
The unicode code point did not work for me:
unicode 代码点对我不起作用:
" U+0022 QUOTATION MARK
Alternatively, this worked for me:
或者,这对我有用:
" " QUOTATION MARK