I’m trying to format a number with no decimals and adding the currency symbol. I get an error if I try to use ‘formatNumber’: Call to protected method CNumberFormatter::formatNumber() from context 'CBaseController.
and also I have the variable default_charset = “iso-8859-1” configured in php.ini, also tried with default_charset = “utf-8”, it’s still not working. Any other thing I could check?
If you set charset in your config/main.php this will not generate the <meta…> tag in HTML for you. The tag is rather in the default views/layouts/main.php.
If your webserver sends another Content-Type header the tag will not help you. The HTTP header has highest precedence. So you need to check that.
If you want to use utf-8 then why do you set the default_charset to "iso-8859-1" in your php.ini? It should be "utf-8".
Maybe the howto was a bit confusing. I’ve cleaned it up a little so maybe you read that again.
I have been trying to solve this for a while now… I just don’t know what else I can check.
I have set a utf-8 in the http header and also I have configured utf-8 as default charset in php.ini, also I have tried in several ways the CNumberFormatter…
I’m not really sure if it’s a charset problem, because with this:
Put a € symbol in a raw test.html file and open that in a browser?
Put “echo ‘€’;” in a test.php file and open that in a browser?
If both don’t work, you still get the wrong charset in your HTTP header. You should verify it e.g. with Firebug or with the Chrome Developer tools (Ctrl + Shift + i -> Network).
The first (test.html) works perfectly, it shows the symbol correctly, however the second one (test.php) shows the same weird symbol �, I have this inside head section:
This is really odd. Your webserver configuration seems right, as it sends the correct Content-Type. And even with PHP’s default settings the simple PHP example should just work. So you probably somehow managed to misconfigure PHP. If you have set default_charset in your php.ini, disable that again. It’s not required and should be left empty. Apart from that i’d even remove that meta tag (at least while you’re testing). It’s not required either and just adds confusion. You can add it back later. It will only be useful if someone saves your webpage locally. For the web, the HTTP Content-Type header is all you need.
EDIT:
Also disable all the mbstring.* settings you might have in your php.ini. BTW What operating system do you use?
I have disabled the default_charset and mbstring.* (it was not enabled previously). Also I have removed the meta_tag. I’m getting the same result, I’m really lost with it, if I try this:
The first line put the currency symbol depending on the locale (‘es’, ‘en’, etc) and the second one the currency symbol is located as setted in the pattern, my question now is:
How to show a number without decimals using formatCurrency (so I can take the advantage of i18n)??