tags:

views:

48

answers:

2

I'm having an issue with the localeconv() in PHP. I'm using a Windows PC.

I set my locale to France using setLocale(LC_ALL, 'fra_fra') function. Then I call the localeconv() function to a variable. When I output that variable, below is what I get.


Array
(
    [decimal_point] => ,
    [thousands_sep] => �
    [int_curr_symbol] => EUR
    [currency_symbol] => �
    [mon_decimal_point] => ,
    [mon_thousands_sep] => �
    [positive_sign] => 
    [negative_sign] => -
    [int_frac_digits] => 2
    [frac_digits] => 2
    [p_cs_precedes] => 0
    [p_sep_by_space] => 1
    [n_cs_precedes] => 0
    [n_sep_by_space] => 1
    [p_sign_posn] => 1
    [n_sign_posn] => 1
    [grouping] => Array
        (
            [0] => 3
        )

    [mon_grouping] => Array
        (
            [0] => 3
        )

)

I'm not sure if it is a UTF-8 display issue. I've done the following:

  1. Set my default_charset in PHP.ini to UTF-8
  2. The Content-type on my page is UTF-8
  3. I've also called same in a header i.e. header('Content-type: text/html; charset=utf-8')
  4. I'm using firefox and changed the charset there too, still no luck
  5. I also updated my http.conf file with AddDefaultCharset, but still no cigar

I'm completely stumped and not sure what next to do.

Can anyone help out?

Thanks.

+1  A: 

I think, your output is not UTF-8. Try to use the UTF-8-locale which such be something like fr_fr.UTF-8 or fr_fr.utf8 on most *nix-systems.

By the way: are you sure about the fra_fra-locale? Shouldn't it be fr_fr for french?

Stefan Gehrig
fr_fr doesn't work on Windows machines. This is noted in the documentation for setlocale() here: http://www.php.net/manual/en/function.setlocale.php. fra_fra does work, but the output is what I can't understand, I've set everything I know possible to utf-8.
Chuck Ugwuh
You're on Windows? UTF-8 is a no-go then. Please see my answer here: http://stackoverflow.com/questions/120334/how-to-sort-an-array-of-utf-8-strings/349036#349036
Stefan Gehrig
I'd assume that the output is either Windows-1252, ISO-8859-1 or ISO-8859-15. Perhaps you can use `iconv` or `mb_convert_encoding` o convert it to UTF-8.
Stefan Gehrig
I got it to work with the following:iconv('Windows-1252', 'UTF-8', $locale_conv_arr['currency_symbol']) i.e. assuming $locale_conv_arr represents the array as defined in my question.I'm doing a jig right now. Thanks Stefan.
Chuck Ugwuh
A: 

I finally got this to work i.e. to display the proper characters.

Just do the following (please note that this is for Windows):

iconv('Windows-1252', 'UTF-8', $locale_conv_arr['currency_symbol']);

Where $locale_conv_arr represents the array previously defined in my question.

Thanks to Stefan Gehrig for the direction.

Cheers.

Chuck Ugwuh