blake305
blake305

Reputation: 2236

Quote not displaying properly

So the characters “ and ” (“ and ” respectively) are variations of the neutral quote ("). I see them in a data sheet 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.

Upvotes: 1

Views: 400

Answers (4)

vusan
vusan

Reputation: 5331

Try charset=WINDOWS-1252"

<meta http-equiv="content-type" content="text/html; charset=WINDOWS-1252" >

Upvotes: 0

Robert
Robert

Reputation: 8767

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.

Upvotes: 2

matzahboy
matzahboy

Reputation: 3024

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');
}

Upvotes: 0

Buddy
Buddy

Reputation: 1836

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.

Upvotes: 0

Related Questions