From 1a2f17c62e0024afe8e8dee5fa4b12403e736a3a Mon Sep 17 00:00:00 2001 From: Simon Wiles Date: Wed, 22 Nov 2023 10:06:34 -0800 Subject: [PATCH] Add Unicode BOM to `/memes.csv` response This should indicate to Windows that it should treat the file as UTF-8. Other systems default to Unicode encodings but Windows won't without a nudge. I can't use `content-type` headers or other solutions on GH pages, so this is the best option. --- src/pages/memes.csv.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/memes.csv.js b/src/pages/memes.csv.js index 8d1fba2b09..56b32fe67f 100644 --- a/src/pages/memes.csv.js +++ b/src/pages/memes.csv.js @@ -29,7 +29,9 @@ const csvStringifier = createObjectCsvStringifier({ }); const csv = - csvStringifier.getHeaderString() + csvStringifier.stringifyRecords(memesRows); + "\ufeff" + // Write a BOM at the start of the output to force Windows systems to recognize the file as UTF-8 + csvStringifier.getHeaderString() + + csvStringifier.stringifyRecords(memesRows); export async function get() { return {