How to specify the required character encoding in a TextEncoder? Or how to get the character code in the required character encoding?

Viewed 54

I need to get the character code in the required character encoding (for example, CP 866). A better solution would be something like:

let encoder = new TextEncoder('ibm866');
let uint8Array = encoder.encode('А');
console.log(uint8Array);

But the problem is that TextEncoder, unlike TextDecoder, does not accept the desired encoding as a parameter, or I did not find how to do it.

At the moment, I only know a workaround with an array, or using a query by PHP, but I would like to find the right solution, without using an additional array (only native JS functions).

0 Answers
Related