This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.IO; | |
namespace KlerksSoft | |
{ | |
public static class TextFileEncodingDetector | |
{ | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import iconv from 'iconv' | |
export const convertToUTF8 = <T extends any>(body: T, fromEncoding = 'iso-8859-1'): T => { | |
const ic = new iconv.Iconv(fromEncoding, 'utf-8') | |
const buf = ic.convert(JSON.stringify(body)) | |
return JSON.parse(buf.toString('utf-8')) | |
} |