用下面的UDF为什么转出来的会比正常的多啊?
像这个:http://so.mdbchina.com/query/%E4%B8%AD%E5%9B%BD
而用UDF转出来的是 %E4%B8%AD%E5%9B%BD%D2%B8%C3%93
而且跟据中文字的不同,多出来的也不同啊?如何解决啊?
%E4%B8%AD 中 "0xe4b8ad00" ;
%E4%B8%AD%E5%9B%BD 中国 E4B8AD E59BBD D2B8C393
%E4%B8%AD%E5%9B%BD%E5%91%80 中国呀 E4B8ADE59BBDE59180 C3930000
%E4%B9%B1%E4%B8%83%E5%85%AB%E7%B3%9F 乱七八糟 E4B9B1E4B883E585ABE7B39F E58995E4958CE48D8EE4918F
#include-once
$a = _UnicodeURLEncode('乱七八糟')
MsgBox ( 0, "1", $a, 45)
Func _UnicodeURLEncode($UnicodeURL)
$UnicodeBinary = StringToBinary ($UnicodeURL, 4)
msgbox (0,"1",$UnicodeBinary)
$UnicodeBinary2 = StringReplace($UnicodeBinary, '0x', '', 1)
msgbox (0,"2",$UnicodeBinary2)
$UnicodeBinaryLength = StringLen($UnicodeBinary2) ;"12"
msgbox (0,"3",$UnicodeBinaryLength)
Local $EncodedString
For $i = 1 To $UnicodeBinaryLength Step 2
$UnicodeBinaryChar = StringMid($UnicodeBinary2, $i,2)
If StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", BinaryToString ('0x' & $UnicodeBinaryChar, 4)) Then
$EncodedString &= BinaryToString ('0x' & $UnicodeBinaryChar)
Else
$EncodedString &= '%' & $UnicodeBinaryChar
EndIf
Next
Return $EncodedString
EndFunc ;==>_UnicodeURLEncode
************************************************************
网站所使用的编码代码如下:
function rd(o)
{
// Override last one
if (o.q.value!=null)
{
var q=filteringQuery(o.q.value);
if (q.length>0)
{
var u=o.action+encodeURIComponent(q);
var parameters=new Array();
var mode=parseInt(o.mode.value);
if (mode!=0)
parameters.push("mode="+mode);
var sortId=getCheckedValue(o.sort);
var orderId=getCheckedValue(o.order);
if (sortId!=0)
parameters.push("sort="+sortId);
if (orderId!=0)
parameters.push("order="+orderId);
if (o.usingdate.checked)
{
var dateFrom=parseInt(o.dfrom.value);
var dateTo=parseInt(o.dto.value);
if (dateFrom>=1900&&dateFrom<=2100)
parameters.push("dfrom="+dateFrom);
if (dateTo>=1900&&dateTo<=2100)
parameters.push("dto="+dateTo);
}
if (o.usingfields.checked)
{
var stack=new Array();
for (var i=0; i<o.field.length; ++i)
if (o.field.checked)
stack.push(o.field.value);
if (stack.length>0)
parameters.push("field="+stack.join("."));
stack=new Array();
for (var i=0; i<menu.selections.length; ++i)
{
var selectValues=new Array();
var options=menu.selections.options;
for (var j=0; j<options.length; ++j)
if (options[j].selected)
selectValues.push(options[j].value);
if (selectValues.length>0)
stack.push(i+"-"+selectValues.join("-"));
}
if (stack.length>0)
parameters.push("select="+encodeURIComponent(stack.join(".")));
}
if (parameters.length>0)
u+="?"+parameters.join("&");
document.location.href=u;
return false;
}
}
o.q.focus();
return false;
}
[ 本帖最后由 net_e 于 2008-8-29 19:33 编辑 ] |