Juquey 实战总结

Juquey 实战总结   



例子:

gb2312.html

 

  1. <html> 
  2. <head> 
  3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  4. <SCRIPT LANGUAGE="JavaScript" src="js/jquery-1.2.4.js"></script> 
  5.  <SCRIPT LANGUAGE="JavaScript"> 
  6.   <!--  
  7.     $(document).ready(function(){  
  8.        $("#btn").click(function(){  
  9.          $.get("php/gb2312.php",function(data){  
  10.              
  11.                 $("#content").html(unescape(data));//这里unescape一下就可以了  
  12.            
  13.          })  
  14.            
  15.        });  
  16.     });  
  17.   //--> 
  18.   </SCRIPT> 
  19. <title>无标题文档</title> 
  20. </head> 
  21.  
  22. <body> 
  23.  <div ID="btn">获得ajax中文</div> 
  24.  <div ID="content"></div> 
  25.  
  26. </body> 
  27. </html> 

gb2312.php

 

  1. <?  
  2. echo escape(" GB2312中文");  
  3. function escape($str) {  
  4.    preg_match_all("/[\x80-\xff].|[\x01-\x7f]+/",$str,$r);  
  5.    $ar = $r[0];  
  6.    foreach($ar as $k=>$v) {  
  7.      if(ord($v[0]) < 128)  
  8.        $ar[$k] = rawurlencode($v);  
  9.      else 
  10.        $ar[$k] = "%u".bin2hex(iconv("GB2312","UCS-2",$v));  
  11.    }  
  12.    return join("",$ar);  
  13. }  
  14. ?>  





评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值