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

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

Open
coudot opened this issue Oct 17, 2024 · 0 comments
Open

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

coudot opened this issue Oct 17, 2024 · 0 comments
Milestone

Comments

@coudot
Copy link
Member

coudot commented Oct 17, 2024

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.

@coudot coudot modified the milestones: 0.5, Backlog Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant