Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add BOM in CSV output if encoding is UTF-8 #11

Open
stevencjhsiao opened this issue Nov 14, 2018 · 3 comments
Open

add BOM in CSV output if encoding is UTF-8 #11

stevencjhsiao opened this issue Nov 14, 2018 · 3 comments

Comments

@stevencjhsiao
Copy link

stevencjhsiao commented Nov 14, 2018

When open output UTF-8 CSV file by excel, if the UTF-8 CSV is lack of BOM header , Excel will identify CSV as ISO-8858-1 encoding. The Chinese character inside the Excel will unreadable.

screen-capture

function toCSV($delm="\t", $add_title=true, $encoding=null)
{
    $out = '';
    // add BOM if UTF-8
    if ($encoding == 'UTF-8')
        $out = chr(239) . chr(187) . chr(191);
@thomascube
Copy link
Owner

From my experience, BOMs usually cause more problems than they solve but in this case, it might make sense. Could you possibly check if the CSV (with BOM) also works when imported in Outlook? That's another very important use-case.

@stevencjhsiao
Copy link
Author

CSV with BOM still can be imported to outlook in my test. The only defect is the first field name will include BOM, but it will not effect the data in first column.

screen-capture2

However, there are still additional two issue when importing Traditional Chinese CSV to outlook.

  1. CSV must use Big5 encoding
  2. the EOL character must be CR+LF

You may consider to add option for BOM and EOL in UI.

@thomascube
Copy link
Owner

The only defect is the first field name will include BOM

This may be a problem with automatic field assignments in Outlook or other applications

You may consider to add option for BOM and EOL in UI

Unfortunately another setting non-tech-savvy users will not understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants