I have a nuxt app and using capacitor to create a mobile version app. Currently I want to save a csv file in mobile app (android). Here is my implementation so far:
const csvData = [
["創建日期", "賬目類型", "標題"],
["2024-03-22", "收入", "發票測試2"]
];
// Convert the CSV data to a CSV string
const csvString = csvData.map(row => row.join(',')).join('n');
// Write the encoded data to a file
const filename = 'data.csv';
const file = await Filesystem.writeFile({
path: filename,
data: csvString,
directory: Directory.Documents,
encoding: Encoding.UTF8
});
await FileOpener.open({
filePath: file.uri,
contentType: 'text/csv',
});
The output csv result doesn’t encoded correctly like this :
Anyone can help?