Reputation: 19888
I am using the following code as an example
$locale = 'cy_GB';
setlocale ( LC_MONETARY , $locale );
$conv = localeconv();
$currencyRateSymbol = $conv['int_curr_symbol'];
var_dump($currencyRateSymbol);
The problem is that I am getting string '�' (length=1)
when I am looking for £
This is happening for every locale that I use including baht, pound and euro. what am I doing wrong?
Upvotes: 2
Views: 2378
Reputation: 522015
length=1
means it's one byte long. "�" means you're trying to display it as Unicode and the Unicode decoder could not decode this byte correctly. The £ symbol encoded in UTF-8 is two bytes.
Ergo...
The £ symbol is not encoded in UTF-8, but you are trying to decode it as UTF-8, hence it fails.
Use the UTF-8 version of your locale if it exists on your system (e.g. cy_GB.UTF-8
) or specify the correct encoding to the client that's trying to display this (probably ISO-8859-1).
Upvotes: 3