php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78457 str_getcsv parses the CSV error
Submitted: 2019-08-26 02:25 UTC Modified: 2019-08-26 07:15 UTC
From: baoguoxiao0538 at hotmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Strings related
PHP Version: 7.3.8 OS: windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: baoguoxiao0538 at hotmail dot com
New email:
PHP Version: OS:

 

 [2019-08-26 02:25 UTC] baoguoxiao0538 at hotmail dot com
Description:
------------
The PHP execution code in the Linux environment is normal, but the execution result in Windows is wrong

Test script:
---------------
var_export(str_getcsv('应收账款上账日期,客户名称,凭证号,摘    要,借方本币,贷方本币,账龄区间,出库日期,回款上账日期,回款天数'));

Expected result:
----------------
array (
        0 => '应收账款上账日期',
        1 => '客户名称',
        2 => '凭证号',
        3 => '摘    要',
        4 => '借方本币',
        5 => '贷方本币',
        6 => '账龄区间',
        7 => '出库日期',
        8 => '回款上账日期',
        9 => '回款天数',
    )

Actual result:
--------------
 array (
        0 => '应收账款上账日期',
        1 => '客户名称',
        2 => '凭证号,摘    要,借方本币',
        3 => '贷方本币',
        4 => '账龄区间',
        5 => '出库日期',
        6 => '回款上账日期',
        7 => '回款天数',
    )

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-08-26 07:01 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2019-08-26 07:01 UTC] cmb@php.net
I can confirm this erroneous behavior for the zh-cn locale; it
works as expected for the en-us locale, though.  So as a
work-around for now, you may consider:

    var_dump(setlocale(LC_ALL, 'en-us'));
    var_export(str_getcsv('应收账款上账日期,客户名称,凭证号,摘    要,借方本币,贷方本币,账龄区间,出库日期,回款上账日期,回款天数'));
 [2019-08-26 07:15 UTC] cmb@php.net
-Status: Verified +Status: Duplicate
 [2019-08-26 07:15 UTC] cmb@php.net
Well, the proper fix for now would be

  setlocale(LC_ALL, 'Chinese_China.65001');

I'm closing this ticket as duplicate of bug #72861.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 21:01:29 2024 UTC