views:

114

answers:

5

Hi,

I have a a strange problem that I can't seem to identify the cause of.

When I use Zend_Currency to format a value to to GBP I get an accented A before the £ symbol. If ask it to return any other curreny such as USD the accented A disappears.

The code that is generating this is:

$currency = new Zend_Currency('en_GB');
$amount = $currency->toCurrency($value);

This displays

£ 500.00

If I set to en_US I get

$ 500.00

Any ideas of why this could be?

Thanks...

A: 

Check your character encoding for the page.

Shadi Almosri
+2  A: 

'funny' characters are generally an encoding/display issue. Make sure you are setting the script to output as UTF8 - check your HTML/Xml headers / content-type.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Alister Bulman
A: 

It is outputting a double-byte character for the pound sign and the browser is not seeing it as such - it is seeing it as two single byte characters.

Check that your script and the rest of the web-page agree which codepage is being used. For instance if the Zend_currency function is assuming (or has been told) UTF8 then you need something like this in the page's :

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
David Spillett
+1  A: 

When you check your encoding, you need to make the HTTP headers match also. If your server is sending the page as ISO8891 and your HTML is self specifying as UTF8, you may have issues in some browsers, choosing the incorrect encoding.

In php you can use the header() builtin function to send http headers to the client. eg;

header('Content-Type: text/html; charset=utf-8');
garrow
A: 

I just had this problem and its because of the encoding issue mentioned above. I was able to solve it using the following snippet

html_entity_decode("&#xA3;", ENT_COMPAT, 'ISO-8859-1');

This blog post talks about it in detail.

rajasaur