首页 > 代码库 > 运行代码
运行代码
试一下:
<script type="text/javascript">// |[\x00-\x20]|[\x7F-\xFF]|[\u0100-\u2700]/g;var encodeHtml = function(s){return (typeof s != "string") ? s :s.replace(REGX_HTML_ENCODE,function($0){var c = $0.charCodeAt(0), r = [""];c = (c == 0x20) ? 0xA0 : c;r.push(c); r.push(";");return r.join("");});};var REGX_HTML_DECODE = /&\w+;|(\d+);/g;var HTML_DECODE = {"<" : "<", ">" : ">", "&" : "&", " ": " ", """: "\"", "©": "?"};var decodeHtml = function(s){return (typeof s != "string") ? s :s.replace(REGX_HTML_DECODE,function($0,$1){var c = HTML_DECODE[$0]; // 尝试查表if(c === undefined){// Maybe is Entity Numberif(!isNaN($1)){c = String.fromCharCode(($1 == 160) ? 32 : $1);}else{// Not Entity Numberc = $0;}}return c;});};var html = encodeHtml(‘
- 测试的内容
- 测试的内容
- 测试的内容
- 测试的内容
运行代码