[nycphp-talk] fgetcsv and German characters
stephen at capellic.com
Tue Aug 14 10:01:37 EDT 2007
Oh, how I love character encoding problems! ;-)
I have a file upload utility whereby the user uploads a CSV
document. The file is saved to a temporary folder. I open that
document, use fgetcsv() to pull the values and then insert them into
The problem is that German characters such as ü and ä are being
translated to Ÿ and Š respectively when I echo the values to the
browser and when inserted into the DB. I wrote the values to the
error log and they come out to \x9f and \x8a respectively.
I learned that I should use the setlocale() function for German:
$loc_de = setlocale(LC_ALL, 'de_DE');
But that didn't do anything for me. I even tried as shown in the
example for setlocale() on php.net:
$loc_de = setlocale(LC_ALL, 'de_DE at euro', 'de_DE', 'de', 'ge');
When I echo $loc_de, both say "de_DE" as expected, but it doesn't fix
my import problem.
I've checked the uploaded file contents and it looks fine.
Any suggestions would be appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the talk