found bug on PHP5

Bug #255895 reported by ouychai
4
Affects Status Importance Assigned to Milestone
php5 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I found a bug while I'm developing the local community website. I'm using php code for display a data from csv file format that you can import from the spreed sheet software.
http://www.sangaban.org/download/bugs/news.csv <=== My data is utf-8
The Code is
<?php
$file = fopen("news.txt","r");
while (!feof($file))
{
print_r(fgetcsv($file,1024));
print "";
}
fclose($file);
?>
This function on PHP can not display the Thai language. I think a bug from function fgetcsv(). I can using fgets for display thai lanuage. I'm using ubuntu 8.04

Revision history for this message
Marc D. (koshy) wrote :

Please show an example (the domain sangaban.org has a broken and a lame delegation and none elsel, so your link does not work) of the problem.

Describe what you expect to happen and what happens instead.

I am not quite familiar with PHP, but I don’t see anything in the above code that is sensitive to differences between ASCII, ISO-8859 or UTF-8.

Revision history for this message
ouychai (ae-freeman) wrote :
Revision history for this message
ouychai (ae-freeman) wrote :

Oh! I'm wrong

<?php
$file = fopen("news.csv","r");
while (!feof($file))
{
print_r(fgetcsv($file,1024));
print "";
}
fclose($file);
?>

This program for read file "news.csv" and display on web site.

Revision history for this message
ouychai (ae-freeman) wrote :
Revision history for this message
Marc D. (koshy) wrote :

This is all documented: http://de.php.net/fgetcsv

“Note: Locale setting is taken into account by this function.”

The default locale is usually C, so Octets 0x80–0xff are undefined and therefore non-printable. Using a UTF-8 locale, your program works as expected. Just add “setlocale(LC_CTYPE, 'en_GB.UTF-8');” as the first command (you can use any UTF-8 locale; if en_GB isn’t installed, try en_US).

Revision history for this message
Marc D. (koshy) wrote :

RTFM

Changed in php5:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.