How can I tell if a CSV is in UTF-7 or UTF-8
Posted
by dru-zod
on Stack Overflow
See other posts from Stack Overflow
or by dru-zod
Published on 2010-04-22T10:10:53Z
Indexed on
2010/04/22
10:13 UTC
Read the original article
Hit count: 629
Excel seems to save CSV files in (what I think is) UTF-7, despite the fact that most information I have read suggest that in general, you should not UTF-7. Indeed, other applications (Text pad, which lets me choose) save things in UTF-8 (or Unicode etc, but UTF-7 is not even an option).
Using .NET, I read the stream, and have to provide the encoding. If I get it wrong, accented characters are replaced with question marks. If I try and let StreamReader work it out (using detectEncodingFromByteOrderMarks), it gets it wrong (at least, it does if the file has been saved in Excel).
It is unlikely that anything other then Excel will be used, so I could just assume UTF-7.
Are there any other options?
I need to support French (accented), German, Dutch, and Norwegian characters.
© Stack Overflow or respective owner