Skip to content

Commit

Permalink
fix: encoding issue for csv export
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Jul 26, 2023
1 parent ad23f8e commit b1b70a6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export const downloadData = (data: string | ArrayBuffer, name: string, type: str
let options: BlobPropertyBag = {};
if (type === 'json') {
blobArr = [JSON.stringify(data)];
} else if (type === 'csv') {
const read = new Uint8Array([0xEF, 0xBB, 0xBF]);
blobArr = [read, data];
options = {type: 'text/csv;charset=utf-8'};
}
const blob = new Blob(blobArr, options);
const url = window.URL.createObjectURL(blob);
Expand Down

0 comments on commit b1b70a6

Please sign in to comment.