Dave,

Thanks, that worked perfect using the en_US.utf8 locale.

I wonder if Drupal's changing of the LC_CTYPE should be documented better since this breaks charset conversions and causes these two functions (iconv() and mb_set_encoding()) to not function as they should.

I also wonder if we should create a drupal_change_encoding() function that resets the locale, does the conversion, and sets the locale back to make life easier for those who don't know about the LC_CTYPE change.

Brian

Dave Reid wrote:
It's because of the call to setlocale(LC_CTYPE, 'C'); in _unicode_check() in includes/unicode.inc.

>From http://www.php.net/manual/en/function.iconv.php#86077 I tried doing the following and it worked for me (very important to note setting back the original value to setlocale().

setlocale(LC_CTYPE, 'fr_FR.utf8');
$string = "Stéphanie,D Hérouville";
$output = iconv("UTF-8", 'ASCII//TRANSLIT', $string);
print $output;
setlocale(LC_CTYPE, 'C');

I'm not sure which locale string you'd use in the first call to setlocale (I used French in this case) but you can get all the values on your system by running locale -a from the command line.

Dave Reid
[email protected]

Reply via email to