Skip to content

Option to add UTF-8 BOM to CSV output #148

@coudot

Description

@coudot

When exporting results as CSV, LibreOffice automatically detects UTF-8 encoding. This is not the case of Microsoft Excel, which requires BOM to select the correct encoding :

It seems easier to adapt in White Pages than patching Microsoft Excel:

diff --git a/lib/csv.inc.php b/lib/csv.inc.php
index 9cd2cb7..69aa9d9 100644
--- a/lib/csv.inc.php
+++ b/lib/csv.inc.php
@@ -27,6 +27,9 @@ function download_send_headers($filename) {
     // disposition / encoding on response body
     header("Content-Disposition: attachment;filename={$filename}");
     header("Content-Transfer-Encoding: binary");
+
+    // UTF-8 BOM
+    echo "\xEF\xBB\xBF";
 }
 
 ?>

But as adding a BOM is not recommended, this should be an option, disabled by default.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions