javascript encode或者decode html
function myHTMLEnCode(str)
{
var s = "";
if (str.length == 0) return "";
s = str.replace(/&/g, "&");
s = s.replace(/</g, "<");
s = s.replace(/>/g, ">");
s = s.replace(/ /g," ");
s = s.replace(/\'/g, "'");
s = s.replace(/\"/g, """);
//s = s.replace(/\n/g, "<br>");
return s;
}
function myHTMLDeCode(str)
{
var s="";
if(str.length ==0) return "";
s = str.replace(/&/g, "&");
s = s.replace(/</g, "<");
s = s.replace(/>/g, ">");
s = s.replace(/ /g, " ");
s = s.replace(/'/g, "\'");
s = s.replace(/"/g, "\"");
s = s.replace(/<br>/g, "\n");
return s;
}
javascript encode或者decode html的更多相关文章
- python的str,unicode对象的encode和decode方法
python的str,unicode对象的encode和decode方法 python中的str对象其实就是"8-bit string" ,字节字符串,本质上类似java中的byt ...
- python的str,unicode对象的encode和decode方法(转)
python的str,unicode对象的encode和decode方法(转) python的str,unicode对象的encode和decode方法 python中的str对象其实就是" ...
- python的str,unicode对象的encode和decode方法, Python中字符编码的总结和对比bytes和str
python_2.x_unicode_to_str.py a = u"中文字符"; a.encode("GBK"); #打印: '\xd6\xd0\xce\xc ...
- [LeetCode] Encode and Decode Strings 加码解码字符串
Design an algorithm to encode a list of strings to a string. The encoded string is then sent over th ...
- 【python】python新手必碰到的问题---encode与decode,中文乱码[转]
转自:http://blog.csdn.net/a921800467b/article/details/8579510 为什么会报错“UnicodeEncodeError:'ascii' codec ...
- LeetCode Encode and Decode Strings
原题链接在这里:https://leetcode.com/problems/encode-and-decode-strings/ 题目: Design an algorithm to encode a ...
- Encode and Decode Strings
Design an algorithm to encode a list of strings to a string. The encoded string is then sent over th ...
- encode和decode
Python字符串的encode与decode研究心得乱码问题解决方法 为什么会报错“UnicodeEncodeError: 'ascii' codec can't encode characters ...
- 【python】浅谈encode和decode
对于encode和decode,笔者也是根据自己的理解,有不对的地方还请多多指点. 编码的理解: 1.编码:utf-8,utf-16,gbk,gb2312,gb18030等,编码为了便于理解,可以把它 ...
随机推荐
- C++数据结构之Stack(栈)
stack,栈,是好比堆积木似的数据结构,从上之下堆积,取出时按"LIFO"-last int first out后进先出的规则.栈一般为线程所独有,也就是每个线程有其自有的栈,与 ...
- hdu 2077
PS:汉诺塔问题....找规律...观察发现,先是小的移动到B,然后大的移动到C(两步),然后小的移动到C,完成.刚开始就以为是f(n)=2f(n-1)+2..然而,小的移动一步是需要f(n)=3f( ...
- 0911 Socket网络编程
1.实现ftp上传.下载功能 1.1 循环接收数据直到接收完毕 server端接收client发送的命令(比如说ifconfig),然后server端将命令执行结果反馈给客户端,这时候有个问题,ser ...
- 转载大神的dfs讲解
http://acm.hdu.edu.cn/forum/read.php?tid=6158 看完明白了好多! 关于剪枝,没有剪枝的搜索不太可能,这题老刘上课的时候讲过两个剪枝,一个是奇偶剪枝,一个是路 ...
- APNS IOS PHP 苹果推送
IOS---APNS 消息推送实践 首先,需要一个pem的证书,该证书需要与开发时签名用的一致. 具体生成pem证书方法如下: 1. 登录到 iPhone Developer Connection P ...
- HDU 5823 (状压dp)
Problem color II 题目大意 定义一个无向图的价值为给每个节点染色使得每条边连接的两个节点颜色不同的最少颜色数. 对于给定的一张由n个点组成的无向图,求该图的2^n-1张非空子图的价值. ...
- dat文件中如何编写DOS的多行命令
dat文件中如何编写DOS的多行命令 2012-10-15 11:29 四海柔情108 分享到: 2012-10-16 23:36 提问者采纳 你问的应该是BAT文件吧?BAT是DOS命令的批 ...
- GOLANG 反射法则
译自[blog.golang.org/laws-of-reflection] 在计算机中, 反射是程序通过类型,检测到它自己的结构能力:是一种元编程程:也是一个具大的混淆点 在本文中,我们将通过解释反 ...
- The Implementation of Lua 5.0 阅读笔记(一)
没想到Lua的作者理论水平这么高,这篇文章读的我顿生高屋建瓴之感.云风分享了一篇中译:http://www.codingnow.com/2000/download/The%20Implementati ...
- 一步一步使用sklearn
http://kukuruku.co/hub/python/introduction-to-machine-learning-with-python-andscikit-learn Hello, %u ...