首先,UTF-8编码的中文字符也是正常的。
如果你认为 gb2312 才“正常”, 可以这样:
$utf8_str = '中文'; // 注意这儿得是 UTF-8 编码的字符串
$gb2312_str = mb_convert_encoding($str, 'GB2312', 'UTF-8');
%E5%90%89%E6%9E%97
有人已经回答了,
用 urldecode 就行了。
用mb_convert_encoding函数转换,你要说明就看下面:
string mb_convert_encoding ( string $str , string $to_encoding [, mixed $from_encoding ] )
Converts the character encoding of string str to to_encoding from optionally from_encoding
也可以用iconv,但这个函数有些情况会出错
你这个不是UTF-8编码,用urldecode来解码,你试试
如下:
<%
key=request("key")
Dim s
dim t
dim i
dim jjjj
dim h
dim l
dim xxxx
s=""
xxxx=Len(key)
For i =1 to xxxx
t = Mid(key,i,1)
jjjj = Asc(t)
If jjjj> 0 Then
If f Then
s = s & "%" & Right("00" & Hex(Asc(t)),2)
Else
s = s & t
End If
Else
If jjjj < 0 Then jjjj = jjjj + &H10000
h = (jjjj And &HFF00) \ &HFF
l = jjjj And &HFF
s = s & "%" & Hex(h) & "%" & Hex(l)
End If
Next
set rs=server.CreateObject("adodb.recordset")
sql="select * from szbus where line like '%"&Key&"%' or title like '%"&Key&"%' or keyworks like '%"&Key&"%' order by ID desc"
rs.open sql,conn,1,1
%>
$a=urldecode("%E5%90%89%E6%9E%97");
$a=mb_convert_encoding($a, 'GB2312', 'UTF-8');
echo $a;
?>
$file="你的字";
$text = mb_convert_encoding("$file", "gbk", "utf-8");
就是这样。
在echo出来 $text