cookie中文转码

//cookie中文转码
var GB2312UnicodeConverter = { //转码
ToUnicode: function(str) { //中文转unicode
return escape(str).toLocaleLowerCase().replace(/%u/gi, ‘\\u‘);
},
ToGB2312: function(str) { //unicode转中文
return unescape(str.replace(/\\u/gi, ‘%u‘));
}
};

  

时间: 2024-08-27 04:12:07

cookie中文转码的相关文章

URL中文转码

  //Driver = Driver.Substring(0, Driver.Length - 1);//截取字符串                               Driver = Server.UrlEncode(Driver);//URL中文转码,Driver为中文                                 Response.Write("<script>window.open('http://.....:8075/WebReport/Rep

python 中文转码

最近在玩一些爬虫,python中文转码刚接触是一件麻烦的事(转换的原理省略) 一般来说有encode('gbk'),edcode('utf8'),decode('gbk'),decode('utf8')可以解决很大一部问题 但是今天遇到了'\\u6210\\u529f'这种格式,上面的三板斧就搞不定了 经过万能的度娘,发现了第一个贴子,叹为观止 http://bbs.chinaunix.net/thread-3674073-1-1.html 代码如下 #!/usr/bin/env python

Jquery.cookie.js 源码和使用方法

jquery.cookie.js源码和使用方法 jQuery操作cookie的插件,大概的使用方法如下 $.cookie(‘the_cookie’); //读取Cookie值$.cookie(’the_cookie’, ‘the_value’); //设置cookie的值$.cookie(’the_cookie’, ‘the_value’, {expires: 7, path: ‘/’, domain: ‘jquery.com’, secure: true});//新建一个cookie 包括有效

JAVA编码(中文转码)问题总结

本章主要分析Java编码和解码的原理,以及中文转码存在的问题做个简单的总结 目录 1  编码基础知识 ISO-8859-1编码 GBK GB2312 UTF-8 2  WEB系统转换编码       原理 Servlet网络传输编码 Struts2 控制编码 Spring 控制编码 3 字符串转字节 4 字节转字符串 1 编码基础知识 ISO-8859-1编码 ISO-8859-1编码是单字节编码,向下兼容ASCII,其编码范围是0x00-0xFF,0x00-0x7F之间完全和ASCII一致,0

跨页面传值之Cookie 中文乱码问题

写入Cookie protected void Button1_Click(object sender, EventArgs e)    {        HttpCookie _ck = new HttpCookie("persion");        _ck.Value = HttpUtility.UrlEncode( "小杨");        _ck.Expires = DateTime.Now.AddDays(1);        Response.Co

javascript中中文转码的方法

js对文字进行编码涉及3个函数: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decodeURIComponent 1.   传递参数时需要使用encodeURIComponent,这样组合的url才不会被#等特殊字符截断.  例如: <script language="javascript"> document.write('<a href="http://passport

为什么 execute(`echo 中文`) 输出中文源码?

为什么 execute(echo 中文) 输出中文源码? import win.ui; /*DSG{{*/ var winform = win.form(text="管道演示";right=495;bottom=431;parent=...) winform.add( btnPing={cls="button";text="findstr";left=24;top=169;right=132;bottom=202;z=1}; edit={cls=

Qt开发中的实用笔记二--中文转码问题和string转换问题:

一,中文乱码转码问题 1,转码三句话:window下默认是GBK格式,linux下默认是UTF-8,看情况转换UTF-8/GBK QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec

关于使用jquery.cookie.js存cookie中文出现乱码问题

一.在Web开发中,有事为了页面之间传值,我们会用到cookie.但是当在cookie中存值为中文汉字时就会出现乱码! 这是一个简单例子: <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script src="../JavaScript/jquery-1.8.2