unable to parse japanese
fsinbad opened this issue · 2 comments
i found SplFileObject has problem in parsing japanese, i dont know where is wrong
code:
$file = new SplFileObject("KYSBJA_1120T041506.csv");
$file->setFlags(SplFileObject::READ_CSV | SplFileObject::READ_AHEAD | SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
$it = new LimitIterator($file, 1);
foreach ($it as $line) {
$array[] = $line;
}
var_dump($array);
csv data:
科目コード,科目名,カナ名,表示名,英語名,単位数,科目種別コード,管理所属コード,単位累積科目フラグ
"CE180001","基礎英語A","キソエイゴA","基礎英語A","Basic English A","1.0","01","00","N"
csv format is UTF-8 BOM , line terminator CRLF
result:
array(1) {
[0]=>
array(8) {
[0]=>
string(8) "CE180001"
[1]=>
string(15) "基礎英語A"
[2]=>
string(36) "キソエイゴA",基礎英語A""
[3]=>
string(15) "Basic English A"
[4]=>
string(3) "1.0"
[5]=>
string(2) "01"
[6]=>
string(2) "00"
[7]=>
string(1) "N"
}
}
where array [2]=> string(36) "キソエイゴA",基礎英語A""
is not correctly parsed.
Please help, thank you.
sorry , my environment problem , anyway it works on server