function prase string to gb2312 in js

 function gb2312(key)
   {
   var r = "";
   for(var i=0;i<key.length;i++)
   {
     var t = key.charCodeAt(i);
     if(t>=0x4e00 || t==0x300A || t==0x300B)
     {
       try
       {
       execScript("ascCode=hex(asc(\""+key.charAt(i)+"\"))", "vbscript"); r += ascCode.replace(/(.{2})/g, "%$1"); }
       catch(e)
        {}
      }
     else{r += escape(key.charAt(i))}
      }
   return r;
    }
posted @ 2009-08-07 15:14  Hanf  阅读(312)  评论(0编辑  收藏  举报
Copyright © 2008-2016 Hanf All Rights Reserved