How to let jtidy not convert Chinese characters into html entities?

508 views Asked by At

I have some html to convert by jtidy, which contains some Chinese characters:

<font>怎么回事</font>

But the result looks like:

<font>&aelig;&#128;&#142;&auml;&sup1;&#136;&aring;&#155;&#158;&auml;&ordm;&#139;</font>

How to configure jtidy and let it not convert Chinese characters into html entities?

2

There are 2 answers

0
cherouvim On
    tidy.setInputEncoding("utf-8");
    tidy.setOutputEncoding("utf-8");

Or what encoding your input and your output are.

0
fpfcarvalho On

see this

http://www.pinyin.info/tools/converter/chars2uninumbers.html

this is the function to convert chinese chars to unicode numbers

function convertToEntities() {
  var tstr = document.form.unicode.value;
  var bstr = '';
  for(i=0; i<tstr.length; i++) {
    if(tstr.charCodeAt(i)>127) {
      bstr += '&#' + tstr.charCodeAt(i) + ';';
    } else {
      bstr += tstr.charAt(i);
    }
  }
  document.form.entity.value = bstr;
}