0

Пишешь let writeStream = fs.createWriteStream("doc.xls", { encoding: 'UTF-8' });

Все работает, а если пытаться менять кодировку : let writeStream = fs.createWriteStream("doc.xls", { encoding: 'WINDOWS-1251' });

Вылезает ошибка :

The value "WINDOWS-1251" is invalid for option "encoding"

1 ответ 1

0

Ну всё же в ошибке сказано :). В доке есть слудеющее:

The character encodings currently supported by Node.js include:

'ascii': For 7-bit ASCII data only. This encoding is fast and will strip the high bit if set.

'utf8': Multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8.

'utf16le': 2 or 4 bytes, little-endian encoded Unicode characters. Surrogate pairs (U+10000 to U+10FFFF) are supported.

'ucs2': Alias of 'utf16le'.

'base64': Base64 encoding. When creating a Buffer from a string, this encoding will also correctly accept "URL and Filename Safe Alphabet" as specified in RFC 4648, Section 5.

'latin1': A way of encoding the Buffer into a one-byte encoded string (as defined by the IANA in RFC 1345, page 63, to be the Latin-1 supplement block and C0/C1 control codes).

'binary': Alias for 'latin1'.

'hex': Encode each byte as two hexadecimal characters. Data truncation may occur for unsanitized input. For example:

Это поддерживаемые на сегодня кодировки.

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими условиями использования и подтверждаете, что прочитали и поняли наши политику конфиденциальности и нормы поведения.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.