We have these characters:
“
and ”
(this is not a regular "
, but some sort of curly one. No idea what it is called)
When we use htmlentities()
, these characters are not converted, and this causes issues later on. Further problem is that we encode our pages in Latin-1
, and we can not save this particular character (so we can not do a replace-and-find, because we can not actually program this into any page).
NOTE: We DO set ENT_QUOTES
, but this has no effect in htmlentities()
.
UPDATE
I now know they are called fancy quotes, among others, and their appropriate html entities are “
and ”
. Now, the question is, why does PHP not convert these characters appropriately? See sample code:
<?php
var_dump(htmlentities($_POST['t'],ENT_QUOTES));
?>
<form action="" method="post">
<input type="t" name="t" />
<button class="button" type="submit">Send</button>
</form>
Result:
Use htmlentities()
It covers all characters that have an html entity equivalent.
htmlentities
UPDATE
You need to alter the charset.
echo htmlentities("“jrod”", ENT_QUOTES, "Windows-1252");
Update 2
<?php
var_dump(htmlentities($_POST['t'],ENT_QUOTES, "Windows-1252"));
?>
<form action="" method="post">
<input type="t" name="t" />
<button class="button" type="submit">Send</button>
</form>
String used: “testing”
Var dump output: string(21) "“testing”"
Mind you, to see the html equivalents you have to view source as the browser renders them accordingly.
There called “fancy quotes,” “smart quotes,” “curly quotes,” “curled quotes,” “curling quotes,” or “curved quotes”
Left Double Quotation Mark “ “
Right Double Quotation Mark ” ”
You may find this link helpfull: http://www.dwheeler.com/essays/quotes-in-html.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With