本站不再更新,歡迎光臨 java開發(fā)技術網(wǎng)
          隨筆-230  評論-230  文章-8  trackbacks-0

          <script language=javascript>
          var ServerMessage
          function utf8to16(str) {
              var out, i, len, c;
              var char2, char3;

              out = "";
              len = str.length;
              i = 0;
              while(i < len) {
           c = str.charCodeAt(i++);
           switch(c >> 4)
           {
             case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
               // 0xxxxxxx
               out += str.charAt(i-1);
               break;
             case 12: case 13:
               // 110x xxxx   10xx xxxx
               char2 = str.charCodeAt(i++);
               out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
               break;
             case 14:
               // 1110 xxxx  10xx xxxx  10xx xxxx
               char2 = str.charCodeAt(i++);
               char3 = str.charCodeAt(i++);
               out += String.fromCharCode(((c & 0x0F) << 12) |
                  ((char2 & 0x3F) << 6) |
                  ((char3 & 0x3F) << 0));
               break;
           }
              }

              return out;
          }

          document.write(utf8to16(unescape("%e5%bf%ab%e4%b9%90%e5%9c%a3%e8%af%9e%ef%bc%81%e4%bb%80%e4%b9%88%e4%bd%bf%e5%9c%a3%e8%af%9e%e5%bf%ab%e4%b9%90%ef%bc%9f%e4%b8%8d%e6%98%af%e9%82%a3%e5%bf%ab%e4%b9%90%e7%9a%84%e9%98%b3%e5%85%89%ef%bc%8c%e4%b9%9f%e4%b8%8d%e6%98%af%e9%b8%9f%e5%84%bf%e7%9a%84%e5%95%81%e5%95%be%ef%bc%9b%e9%82%a3%e6%98%af%e6%84%89%e5%bf%ab%e7%9a%84%e5%bf%b5%e5%a4%b4%e5%92%8c%e5%b9%b8%e7%a6%8f%e7%9a%84%e7%ac%91%e5%ae%b9%ef%bc%8c%e6%98%af%e6%b8%a9%e9%a6%a8%e6%85%88%e7%88%b1%e7%9a%84%e9%97%ae%e5%80%99%e3%80%82")));
          </script>

          posted on 2008-04-01 10:57 有貓相伴的日子 閱讀(6586) 評論(1)  編輯  收藏 所屬分類: web-demo

          評論:
          # re: 把utf-8字符轉(zhuǎn)換成16進制編碼方式 2014-05-16 10:51 | 二毛
          看著有些怪異,不知道什么情況下會用到這個方法,不過寫的不錯。  回復  更多評論
            
          <2014年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          常用鏈接

          留言簿(32)

          隨筆分類(222)

          隨筆檔案(224)

          文章分類(4)

          文章檔案(7)

          相冊

          收藏夾(4)

          最新評論

          閱讀排行榜

          評論排行榜

          本站不再更新,歡迎光臨 java開發(fā)技術網(wǎng)
          主站蜘蛛池模板: 张掖市| 鄱阳县| 巧家县| 张家口市| 长武县| 哈尔滨市| 宕昌县| 日土县| 台湾省| 舒城县| 玉溪市| 综艺| 大方县| 兰州市| 定日县| 黔南| 义乌市| 阿巴嘎旗| 大悟县| 龙海市| 武平县| 北票市| 霍城县| 彭山县| 云浮市| 泰州市| 双辽市| 拉孜县| 深圳市| 宽甸| 九江县| 潜江市| 西昌市| 攀枝花市| 长治县| 甘德县| 延津县| 文昌市| 巧家县| 大关县| 顺义区|