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等,编码为了便于理解,可以把它 ...
随机推荐
- Python OpenCV——Image
最近看MATLAB有点看不下去...就忍不住回到python的怀抱.研究下OpenCV,就当放松啦,对视觉还是很感兴趣的. 这里和之后代码大部分是来自这里的文档. 首先是对图片的处理. ''' imp ...
- C# asp.net IIS 在web.config和IIS中设置Session过期时间
有时候在web.config设置sessionState 或者类文件里设置Session.Timeout,在IIS里访问时每次都是达不到时间就超时,原因是因为在IIS中设置了Session的超时时间, ...
- Rest文件上传
文件上传时传过来一个stream 代码如下: /// <summary> /// 上传文件 /// </summary> /// <param name="fi ...
- linode空间lamp环境的搭建
安装LAMP的命令如下,请依次执行: apt-get updateapt-get upgrade –show-upgradedapt-get install apache2a2enmod rewrit ...
- CentOS 6.6 nginx PHP 配置
/************************************************************************* * CentOS 6.6 nginx PHP 配置 ...
- C++学习笔记1:高级语言
笔记参考资料:http://www.learncpp.com/ 1.high languages:C,C++,Pascal,Java,Javascript,Perl... compiling proc ...
- word 无法显示图片问题解决
1 打开Word文档,点击“Office按钮”→“Word选项”. 2 在打开的“Word选项”对话框中,点击左侧的“高级”选项卡,在右侧找到“显示文档内容”栏目,取消勾选“显示图片框”.
- javascript中 IE事件处理程序中try catch用法
本例是学习中笔记 望指正批评! <input id='b1' type='button' value='按钮'/> <script> window.onload=functio ...
- IE6无法加载CSS
问题:写了个页面,IE7和IE8下正常,但发现IE6下竟然没有加载css样式. 找原因,发现是因为CSS文件的编码不正确,页面是采用utf-8编码的,但样式表是复制过来的,编码是ANSI,这种情况下在 ...
- sql server导入mdf 报操作系统错误 5:“5(拒绝访问。)”
错误一:拒绝访问 在安装示例库时出现以下的错误 消息 5120,级别 16,状态 101,第 1 行无法打开物理文件"D:\Download\AdventureWorks2012_Data. ...