Accented characters getting corrupted when parsing CSV file

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I am writing a script that allows people to upload a CSV file for
processing and I am having trouble with accented characters.  If a
UTF-8 encoded file is uploaded, everything works fine.  The problem
happens when someone uploads a non UTF8 file that happens to have an
accented character inside, likeA9.  In this case, the character is
converted to a funky symbol, likeBF=BD.

I noticed this explanation in the PHP documentation for the "fgetcsv"
that I am using to read the file: "Note: Locale setting is taken into
account by this function. If LANG is e.g. en_US.UTF-8, files in one-
byte encoding are read wrong by this function."

So my question is, how do I get around this? My script needs to be
able to handle a UTF8 file and a non-UTF8 file with accents.  It seems
like I can only pick one.  Anyone know of a way to convert the funky
symbol back to the accented character?


Site Timeline