Hi there.
In Japan, the common encoding of csv file is shift-jis.
I need shift-jis encoded csv file to register shipping data to shipping company in Japan.
Not limited to this case, there are many situations in Japan where shift-jis format CSV files are required.
I couldn't come up with an idea to achieve this on Retool, so I use my own API to generate a CSV and return a download link.
I want to achieve this with Retool.
Below is an example of exporting shift-jis encoded csv (not fit to Retool).
<body>
<a id="download" href="#" download="data.csv" target="_blank">download</a>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/4.3.7/papaparse.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/encoding-japanese/1.0.28/encoding.min.js"></script>
<script>
const csv = Papa.unparse(values)
// convert csv into shift-jis array with encoding.js
const codeArr = Encoding.convert(csv, {
from: 'UNICODE',
to: 'SJIS',
type: 'array'
})
// array to blob
const uint8Array = new Uint8Array(codeArr)
const blob = new Blob([ uint8Array ], { type: 'text/csv' })
// set a download link to element
window.URL = window.URL || window.webkitURL
document.getElementById("download").href = window.URL.createObjectURL(blob);
</script>
</body>
Is there any idea to export shift-jis encoded csv on Retool?
Thank you.