Bogopodoben2017-01-16 09:21:55
Bogopodoben, 2017-01-16 09:21:55

Angular how to solve encoding problem when saving file from request?

Good afternoon.
The task is this, I receive text from the server and save it in txt with windows-1251 encoding.
The problem is the following, the text comes from the server in windows-1251, and on the client, through the blob and the FIleSaver plugin , I save it to a file, but js will recode it all into utf-8.
An example of saving a file.

                var data = new Blob([res.data], { type: 'text/plain;charset=windows-1251' });
                FileSaver.saveAs(data, 'payment_orders.txt');

How to recode back to windows-1251 to save the file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Кирилл Копица, 2022-01-07

Сталкивался с подобной проблемой, решение описал в ответе на свой же вопрос.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question