text - Android Encoding for this character set -
i getting html text website. site return character shown in below figure. tried find character set site, found <meta http-equiv="content-type" content="text/html; charset=windows-1252">

it show output on device after set in text view like:

i tried coding doesn't effect text,which shown below:
final charset windowscharset = charset.forname("windows-1252"); final charset utfcharset = charset.forname("utf-8"); final charbuffer windowsencoded = windowscharset.decode(bytebuffer .wrap(ne.scrape_detail_article_text.getbytes())); final byte[] utfencoded = utfcharset.encode(windowsencoded).array(); // system.out.println(new string(utfencoded, utfcharset.displayname())); string s = "" ; try { // string s = new string(utfencoded, utfcharset.displayname()); //string s = new string(texttoencoding.getbytes("windows-1252"),"utf-8"); s = urlencoder.encode(texttoencoding, "windows-1252"); log.e("log", "encoded >> " + s); } catch (unsupportedencodingexception e) { log.e("utf8", "conversion", e); } textviewtoset.settext(html.fromhtml(texttoencoding); textviewtoset.setmovementmethod(linkmovementmethod.getinstance()); please me, how can encode text utf-8 , display in textview?
thanks in advance
looks dealing html-entites here. therefore have decode html entities via:
string text = html.fromhtml(yourtext).tostring(); this give correct utf-8 characters. documentation html.fromhtml() here
Comments
Post a Comment