How to convert utf8 to ANSI CP1252 codification in TypeScript?

Viewed 17

I need to create a report with this codification, but I have not find any information about this in Js or Ts with Node.js

Is there are any function to encode the text?

1 Answers

I solved my problem with this function provided by github copilot

//function to convert utf8 to ANSI CP1252
convertToANSI(text: string): string {
    return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
}
Related