Are there different types of double quotes in utf-8 (PHP, str_replace)?

回眸只為那壹抹淺笑 提交于 2019-11-26 17:13:04

问题


In PHP 5.3, am trying to replace double quotes in a string as such:

$bar = str_replace('"','\'',$foo);

But some quotes that are saved in the utf8-Database are not being replaced, although they look perfectly normal:

"Some text"

Are there different character types I have to search for? If so, which are they?


回答1:


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 ".

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.




回答2:


Here is a list of all the characters in Utf-8. It could possibly be two single quotes..




回答3:


Able to insert a quotation using "numerical HTML encoding of the Unicode character"

http://www.utf8-chartable.de/unicode-utf8-table.pl?unicodeinhtml=dec&htmlent=1

The unicode code point did not work for me:

"   U+0022 QUOTATION MARK

Alternatively, this worked for me:

"   "  QUOTATION MARK


来源:https://stackoverflow.com/questions/18735921/are-there-different-types-of-double-quotes-in-utf-8-php-str-replace

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!