ID:               31740
 Updated by:       [EMAIL PROTECTED]
 Reported By:      arjan at avoid dot org
 Status:           Open
-Bug Type:         Filesystem function related
+Bug Type:         Documentation problem
 Operating System: Linux (Suse)
 PHP Version:      5.0.3
 New Comment:

Yeah, we should have some information that tells people that the locale
setting have effect on this, recategorizing...


Previous Comments:
------------------------------------------------------------------------

[2005-01-29 12:07:35] arjan at avoid dot org

The LANG environment variable on the faulty machines was set like
this:
   LANG="en_US.UTF-8"

When changed to
   LANG="en_US"

The problem is fixed. Thanks a lot!
However, shouldn't this behaviour be mentioned in the
manual for fgetcsv? I can imagine more people experiencing
this 'bug' that turns out to be not a bug...

Thanks again!

------------------------------------------------------------------------

[2005-01-29 03:33:57] [EMAIL PROTECTED]

What locale specifier is set to LANG or LC_CTYPE 
environment variable?



------------------------------------------------------------------------

[2005-01-28 20:28:51] arjan at avoid dot org

In order to narrow the problem down as much as I can, I tried the
following script as well on the system that have problems with
fgetcsv:

<?php
   $fp = fopen('csv_test.csv', 'r');
   while (!feof($fp)) {
      $buffer = fgets($fp, 4096);
      echo $buffer;
   }
   fclose($fp);
?>

In this case, the umlauts do get read and printed.

------------------------------------------------------------------------

[2005-01-28 19:37:55] arjan at avoid dot org

Tested the same script on another machine (Suse 9.0), with PHP5.0.3
installed: problem does not occur here.
We have two (identically installed) machines on which this bug does
occur though.
Can anyone point us in some direction as to what might cause this
peculiar behaviour?

------------------------------------------------------------------------

[2005-01-28 12:52:34] arjan at avoid dot org

Description:
------------
fgetcsv on PHP5.0.3 has problems with reading CSV-fields that start
with an umlaut character (possibly other 'weird' characters as well).
It simply skips those characters.

PHP4.3.10 works fine.

Reproduce code:
---------------
csv_test.php:

<?php
   $fp = fopen('csv_test.csv', 'r');
   while($data = fgetcsv($fp, 2000, ';', '"')) {
      var_dump($data);
   }
   fclose($fp);
?>

csv_test.csv:

language_name;country_name
Deutsch;�sterreich
Nederlands;Nederland
Deutsch;Deut�land
�nited Kingdom

Expected result:
----------------
array(2) {
  [0]=>
  string(13) "language_name"
  [1]=>
  string(12) "country_name"
}
array(2) {
  [0]=>
  string(7) "Deutsch"
  [1]=>
  string(9) "�sterreich"
}
array(2) {
  [0]=>
  string(10) "Nederlands"
  [1]=>
  string(9) "Nederland"
}
array(2) {
  [0]=>
  string(7) "Deutsch"
  [1]=>
  string(9) "Deut�land"
}
array(1) {
  [0]=>
  string(13) "�nited Kingdom"
}


Actual result:
--------------
array(2) {
  [0]=>
  string(13) "language_name"
  [1]=>
  string(12) "country_name"
}
array(2) {
  [0]=>
  string(7) "Deutsch"
  [1]=>
  string(9) "sterreich"
}
array(2) {
  [0]=>
  string(10) "Nederlands"
  [1]=>
  string(9) "Nederland"
}
array(2) {
  [0]=>
  string(7) "Deutsch"
  [1]=>
  string(9) "Deut�land"
}
array(1) {
  [0]=>
  string(13) "nited Kingdom"
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31740&edit=1

Reply via email to