You are here:  » Encoding with dollar symbols

Support Forum



Encoding with dollar symbols

Submitted by howardtheblack on Thu, 2007-12-06 20:14 in

Hello Dave,

I ran into a problem that when I try to parse the dollar symbols, it returns characters that are not defined in the character set.

The xml files are encoded in UTF-8 format and I have set the php and mysql char set also to UTF8, the following are the samples:

The source XML

  <?xml version="1.0" encoding="utf-8" ?>
- <inventory>
- <info>
  <pCode>WSO<pCode>
  <price>EUR €300</price>
  </info>
  </inventory>

Charset defined in my php code

<?php
header
("Content-Type: text/html;charset=utf-8");
?>

Mysql charset setting
utf8_unicode_ci

And when I parse the element in the tag, the output becomes: EUR €150 instead of EUR €300.

Please help.

Submitted by support on Fri, 2007-12-07 09:19

Hi,

There is the possibility that whilst the feed has been declared as utf-8, the Euro symbol encoding may actually be iso-8859-1.

What I normally do in this situation is try to find out the correct encoding by modifying the encoding setting in the browsers View > Character Encoding menu. Once you have found the correct one, you can set that as character set the header. Another option is to view the original XML directly in your web browser, check the display, and adjust the character encoding if necessary.

However, if other parts of the feed are actually in utf-8, then it might be necessary to use PHP's utf8_encode() function - perhaps at the point where you insert into the database.

http://uk.php.net/manual/en/function.utf8-encode.php

If this doesn't help and it is still being displayed incorrectly, would it be possible for you to email the original XML (zipped if it is large) to me and I'll take a look for you? Reply to your forum registration or reg code email is the easiest way to get me...

Cheers,
David.