Question

When I read from a csv file with fgetcsv method it removes "Å" and "Ø" if they are at the beginning of the string.

while (($data = fgetcsv($handle, 0, "\t")) !== FALSE) {
        echo $data[0]."<br />";
}

assume my csv contains only one row ÅbyÅÅÅÅhøjÅ, the output is byÅÅÅÅhøjÅ (note lack of the "Å" at the beginning)

any ideas?

Was it helpful?

Solution 2

I have just wrapped input in quotes - now always first character for strings will be ".

OTHER TIPS

From the documentation of fgetcsv:

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.

This means you will need to match the encoding of your string to your locale setting (or vice versa). There is also a bug report on bugs.php.net concerning the inconsistent handling of unexpected characters in the input string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top