Skip to content

Commit

Permalink
Add Unicode BOM to /memes.csv response
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
simonwiles committed Nov 22, 2023
1 parent 4e08148 commit 1a2f17c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pages/memes.csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1a2f17c

Please sign in to comment.