javaScript 中有 unicode 编码转换吗?
我在HTML中直接指定:<meta http-equiv=Content-Type content=text/html; charset=gb2312>的。
并且,已经不是处在服务端了,java中的转换功能用不上。
急呀,同志们,贡献你们的聪明才智,救兄弟于水火之中呀!

解决方案 »

  1.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <script type="text/javascript">
    <!--
    var TranscriptionsLayer;
    var snum = new Array();  snum[0]='\u3007<br>';
      snum[1]='\u4e00<br>';
      snum[2]='\u4e8c<br>';
      snum[3]='\u4e09<br>';
      snum[4]='\u56db<br>';
      snum[5]='\u4e94<br>';
      snum[6]='\u516d<br>';
      snum[7]='\u4e03<br>';
      snum[8]='\u516b<br>';
      snum[9]='\u4e5d<br>';var
      sten = new Array();  sten[0]='';
      sten[1]='\u5341<br>';
      sten[2]='\u5eff<br>';
      sten[3]='\u5345<br>';
      sten[4]='\u534c<br>';
      sten[5]='\u4e94<br>\u5341<br>';var
      jfancy = new Array();
      jfancy[0]='';
      jfancy[1]='\u58f1<br>';
      jfancy[2]='\u5f10<br>';
      jfancy[3]='\u53c2<br>';
      jfancy[4]='\u8086<br>';
      jfancy[5]='\u4f0d<br>';
      jfancy[6]='\u9678<br>';
      jfancy[7]='\u67d2<br>';
      jfancy[8]='\u634c<br>';
      jfancy[9]='\u7396<br>';
      jfancy[10]='\u62fe<br>';
      hanzero='\u96f6<br>';
      hanht='\u6642<br>';
      hanmt='\u5206<br>';
      hanst='\u79d2<br>';function givehan(inwhat, inhow) {var outwhat = '';
      if (inwhat == 0)
      {
        if (inhow == 1)
          {outwhat = snum[0] + snum[0]}
        else
          {outwhat = hanzero}
      }
      else
      {
        if (inhow == 0) {
          var
            outbegin = '';
          var
            outmiddle = '';
          var
            outend = '';      if (inwhat >= 20)
            {outbegin = snum[Math.floor(inwhat / 10)]};
          if (inwhat >= 10)
            {outmiddle = sten[1]};
          if (inwhat % 10 != 0)
            {outend = snum[inwhat % 10]};      outwhat = outbegin + outmiddle + outend;
        };    if (inhow == 1)
          {outwhat = snum[Math.floor(inwhat / 10)] + snum[inwhat % 10]};
        if (inhow == 2) {
          var
            outend = '';
          var
            outbegin = sten[Math.floor(inwhat / 10)];      if (inwhat % 10 != 0)
            {outend = snum[inwhat % 10]};      outwhat = outbegin + outend;
        };    if (inhow==3) {
          var
            outbegin = '';
          var
            outmiddle = '';
          var
            outend = '';      if (inwhat >= 11)
            {outbegin = jfancy[Math.floor(inwhat / 10)]};
          if (inwhat >= 10)
            {outmiddle = jfancy[10]};
          if (inwhat % 10 != 0)
            {outend = jfancy[inwhat % 10]};      outwhat = outbegin + outmiddle + outend;
        };
      };  return outwhat;
    };
    function hanstart(how) {var now = new Date();
      hour = now.getHours(); // military
      minute = now.getMinutes();
      second = now.getSeconds();  foo = givehan(hour, how) + hanht + givehan(minute, how) + hanmt +
        givehan(second, how) + hanst;
      return foo;
    };
    // The style numbers:
    // 0 = neutral
    // 1 = short
    // 2 = like neutral but also special hanzi for '20' and '30'
    // 3 = very ornate, Japanese stylevar HanClockStyle = 3;function upclock()
    {
        var HanclockLayer = document.getElementById('hanclock');
        HanclockLayer.innerHTML = hanstart(HanClockStyle);
    }function Initialize()
    {
        upclock();
        setInterval("upclock()", 1000);
    }//-->
    </script>
    </head><body onload="Initialize();">
    <div id="hanclock" style="font-size: 18pt; font-weight: bold; color: #FFDF00; border: 5px ridge yellow; background-color: black; float:left; height:380px; margin-right:20px">
    </div>
    </body>
    </html>