encoding - Javascript function to replace iso-8859-2 characters with utf8 characters -


i'm gathering data websites nodejs, request , cheerio, 1 site has iso-8859-2 charset , characters not appear correctly.

i tried use iconv-lite, iconv.encode(str, "utf-8") or iconv.decode(str, "utf-8") gave me same output or hexadecimal value. plan create function replaces hungarian iso-8859-2 characters uft8 characters (since there few characters , of them has exact match except 2 has relative match).

the first issue don't know how grab iso-8859-2 values. gave sample string contains (but not all!) values, i'm sure there's better solution. idea put iso-8859-2 charachters , utf-8 characters in array , use replace method change values.

var teststring = "besz�ll�t�";  var = teststring.substring(4, 7); teststring = teststring.replace(a, "\xe1");  var = teststring.substring(7, 10); teststring = teststring.replace(i, "\xed");  var o = teststring.substring(9, 12) teststring = teststring.replace(o, "\xf3"); 


Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -