So the characters “ and ” (“
and ”
respectively) are variations of the neutral quote ("). I see them in a data sheet开发者_如何学Go I have that is full of html and am trying to find and replace them using php.
First, I am testing to see how to reproduce it. Here is my php code:
<?php
echo chr(8220);
?>
Why doesn't this work? I have tried other numbers in the char()
function and it worked fine. I have tried setting the character set to UTF-8
and ISO-8859-1
but it didn't work. How do I make this echo the quote?
I am trying to echo it because I am trying to integrate it into the php code. I know I can just copy and paste it but that will be too confusing to me.
Try:
$str = str_replace(chr(147), '"', $str); // left double quote
$str = str_replace(chr(148), '"', $str); // right double quote
Where 147
and 148
respectively equal left and right double quotes.
chr()
will output only ASCII characters.
Use echo chr(34)
. 34 is decimal number for double quote in ASCII table. There is only 128 (0-127) characters in standard ASCII table. PHP support extended ASCII with 256 characters.
Have you tried the function mb_convert_encoding?
See this explanation on the php docs for how to get the character from its html encoding. Here is the function that that person defined (directly copied from that link):
function unichr($u) {
return mb_convert_encoding('&#' . intval($u) . ';', 'UTF-8', 'HTML-ENTITIES');
}
Try charset=WINDOWS-1252"
<meta http-equiv="content-type" content="text/html; charset=WINDOWS-1252" >
精彩评论