[development] Converting UTF8 strings to ASCII in Drupal

Dave Reid dave at davereid.net
Mon Nov 16 16:14:18 UTC 2009


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
dave at davereid.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20091116/131c1caa/attachment.html 


More information about the development mailing list