From f626d298439f9ffb6656acd0985b4d35923feeb9 Mon Sep 17 00:00:00 2001
From: Cyril Roelandt <tipecaml@gmail.com>
Date: Sat, 21 Jan 2017 04:33:13 +0100
Subject: [PATCH] CSV export: add UTF-8 BOM header.

When exporting a poll to CSV, no BOM character is written. Most applications can
properly detect the required encoding, but some do not, and might find it
helpful to be able to read a BOM character.

--
Comment added 2019-04-16, nico@bou.io:

The issue is specifically with Excel that assumes Latin-1 by default, but switches to utf-8 if a BOM is present. On the other hand, LibreOffice and other apps seem to behave correctly with a BOM.
---
 exportcsv.php | 1 +
 1 file changed, 1 insertion(+)

diff --git a/exportcsv.php b/exportcsv.php
index 6507d6bc..c60b7fff 100644
--- a/exportcsv.php
+++ b/exportcsv.php
@@ -73,6 +73,7 @@ $slots = $pollService->allSlotsByPoll($poll);
 $votes = $pollService->allVotesByPollId($poll_id);
 
 // CSV header
+echo "\xEF\xBB\xBF"; // BOM character for UTF-8
 if ($poll->format === 'D') {
     $titles_line = ',';
     $moments_line = ',';
-- 
GitLab