ashtuchkin / iconv-lite

Convert character encodings in pure javascript.
MIT License
3.04k stars 282 forks source link

How to stop iconv-lite from automatically console.log the entire document #314

Closed dxcqcv closed 9 months ago

dxcqcv commented 9 months ago

The node.js print all csv content in terminal when I run following code, I do not know why and how do I to fix it, I do not wanna console.log anything, and my code does not have console.log command, why does it print file content? help

const fs = require('fs')
const path = require('path')
const iconv = require('iconv-lite');

const xlsxFilePath = path.resolve(__dirname, './csv/demo.csv')

const fileBuffer = fs.readFileSync(xlsxFilePath );
const encodedData = iconv.decode(fileBuffer, 'GBK');
fs.createReadStream(encodedData )
ashtuchkin commented 9 months ago

iconv-lite does not print anything anywhere either. Can it be that fs.createReadStream(encodedData) is used incorrectly? It accepts file path as the first argument.

dxcqcv commented 9 months ago

You're right, my bad, iconv.decode(fileBuffer, 'GBK'); return string not path, thx