A
A
Alex2017-02-16 10:11:18
Node.js
Alex, 2017-02-16 10:11:18

How to read a text file in nodeJs if you don't know its encoding?

You need to read the contents of a plain text file (.csv). The problem is that the files come from different platforms and in different encodings (UTF-8, UTF-16, Windows 125x, etc.). And when using it, FS.readFileSuncyou must specify the encoding explicitly. And if the file is different, then the contents of the file break.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lynn "Coffee Man", 2017-02-16
@Lynn

when using FS.readFileSunc, you must specify the encoding explicitly

It is not true.
lmgtfy.com/?q=node+detect+encoding

O
Oleg, 2017-02-16
@werty1001

Try to find out the encoding:
detect-character-encoding
chardet

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question