Convert ISO-8859-1 to UTF-8 [duplicate]

扶醉桌前 提交于 2019-11-28 12:19:30
Niko

Try the trick shown in: How do I convert special UTF-8 chars to their iso-8859-1 equivalent using javascript?

in your case you could simply use:

utfstring = unescape(encodeURIComponent(ajaxreturn));

Edit: if this does not work either, try the other way round:

fixedstring = decodeURIComponent(escape(ajaxreturn));

It might also help if you post the output of the "encode" functions - this way its possible to identify what's going on:

encodeURIComponent(ajaxreturn)
        vs.
escape(ajaxreturn)

If none of these work I guess you should convert your whole page to be iso-8859-1:

 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!