PHP怎么把经过UTF-8编码的中文字符转换成正常的中文

要把指定的一组经过UTF-8编码的中文字符转换成正常的简体中文
请高手给出完整的代码,并给写出详细的注释 谢谢!
我试了mb_convert_encoding函数,可是不行啊,我要转换的字符串是这种编码的,不知道这是不是UTF-8编码
%E5%90%89%E6%9E%97
我用别的工具转了下这组编码,工具显示是 “吉林”,请高手在给想想办法吧,请说详细点,再次感谢!

首先,UTF-8编码的中文字符也是正常的。
如果你认为 gb2312 才“正常”, 可以这样:
$utf8_str = '中文'; // 注意这儿得是 UTF-8 编码的字符串
$gb2312_str = mb_convert_encoding($str, 'GB2312', 'UTF-8');

%E5%90%89%E6%9E%97
有人已经回答了,
用 urldecode 就行了。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-01-26
用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来解码,你试试
第2个回答  推荐于2016-10-09
如下:
<%
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
%>
第3个回答  推荐于2018-02-28
<?
$a=urldecode("%E5%90%89%E6%9E%97");
$a=mb_convert_encoding($a, 'GB2312', 'UTF-8');
echo $a;
?>本回答被提问者和网友采纳
第4个回答  2010-01-26
$file="你的字";
$text = mb_convert_encoding("$file", "gbk", "utf-8");

就是这样。

在echo出来 $text

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网