Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

quotes

utf-8

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?

like image 724
Urs Avatar asked Sep 11 '13 08:09

Urs


1 Answers

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.

like image 175
Joni Avatar answered Sep 27 '22 21:09

Joni