ganandit / php-excel-reader

Automatically exported from code.google.com/p/php-excel-reader
0 stars 0 forks source link

Csv Reader (CSV.php) Unable to read chinese text in Unicode, UTF 8 files #138

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
try 
{
  $fileName = 'tmp/test.csv';
  $fileType = PHPExcel_IOFactory::identify($fileName);
  $excelReader = PHPExcel_IOFactory::createReader($fileType);
  $excelReader->setSheetIndex(0);
  $excelReader->setDelimiter('  ');
  $excelFile = $excelReader->load($fileName);           
  var_dump($excelFile);
} 
catch (Exception $e) {
  die("Error loading file: ".$e->getMessage()."<br />\n");
}
What is the expected output? What do you see instead?
I am expecting this code to pick up chinese String in B1 (see attached file 
test.csv)

Please provide any additional information below.
File test.csv has been created by using notepad saving file using encoding UTF8.

Original issue reported on code.google.com by s...@blubolt.com on 27 Jan 2012 at 12:29

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
with function 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.

solustion: 
setlocale(LC_ALL, 'zh_CN');

http://my.oschina.net/phpfunction/blog/93543

Original comment by wangguan...@gmail.com on 3 Dec 2012 at 3:47