日期:2014-05-17  浏览次数:20667 次

wap xhtml 中文乱码问题

静态 xhtml mp页面,使用UTF-8编码,在PC Opera下正常显示,手机上打开出现中文乱码,代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>用户登录 - 腾云科技主动防伪系统</title>
</head>
<body>
<form action="index.xhtml">
<p>用户编号<br /><input name="txtUserId" type="text" /><br /></p>
<p>密码<br /><input name="txtUserPwd" type="password" /><br /></p>
<p><input name="btnLogin" type="submit" value="登录" /><br /></p>
<p><input name="btnReset"  type="reset" value="重置" /><br /></p>
</form>
</body>
</html>

?修改为如下解决:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<title>用户登录 - 腾云科技主动防伪系统</title>
</head>
<body>
<form action="index.xhtml">
<p>用户编号<br /><input name="txtUserId" type="text" /><br /></p>
<p>密码<br /><input name="txtUserPwd" type="password" /><br /></p>
<p><input name="btnLogin" type="submit" value="登录" /><br /></p>
<p><input name="btnReset"  type="reset" value="重置" /><br /></p>
</form>
</body>
</html>

?区别:

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
?另外,这一句应写在<title>标签之前;