求1个JS 页面 编译UTF8 通用方法 在线等谢谢

I_Like_Move 2010-01-13 05:00:44
网络上找的EncodeUtf8 这个 在编译这些 如: “特7” 这样的字段时候 就丢失 “7” 只有“特”

求个大家用过的没BUG 的 谢谢

网络上的是这个function EncodeUtf8(s1)
{
var s = escape(s1);
var sa = s.split("%");
var retV ="";
if(sa[0] != "")
...........
...........
...全文
55 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
I_Like_Move 2010-01-13
  • 打赏
  • 举报
回复
楼上的朋友 先谢谢

不过我要的是个 JS utf8编码转换方法 搜的那个有BUG
leefree23 2010-01-13
  • 打赏
  • 举报
回复
不知道你是不是用在读取COOKIE操作,给你个示例

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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>

<script type="text/javascript">
function writeCookie(name, value, hours)
{
var expire = "";
if(hours != null)
{
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire;
}
function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);
if (offset != -1)
{
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end))
}
}
return cookieValue;
}

writeCookie("aa","特7",24)
alert(readCookie("aa"))
</script>
</body>
</html>



千游 2010-01-13
  • 打赏
  • 举报
回复
只用gbk,呵呵

87,955

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧