I’m trying to read an XML document which contains ™ (™), but for some reason, no matter what I try, it always displays as â„¢.
For example:
$xml = new SimpleXMLElement('<item><title>test</title></item><item><title>™</title></item>');
foreach ($xml->item AS $item)
{
echo $item->title . "<br />";
}
Results in:
test
â„¢
Just to be clear, I don’t want it to just show appropriately, I need to insert it to a DB.
Thanks!
The code in your original post works fine for me, at least if I add
<xml>tags. Make sure the content encoding of your HTML page is set correctly, i.e. send the HTTP headerContent-Type:text/html; charset=UTF-8or set this in your<head>. When inserting the string containing this symbol into the database, first set the character set to UTF-8 usingSET NAMES UTF8. Of course, the database/table/field into which you are inserting should be set to UTF8 too.