convert.js
来自「beyondplus留言本 JSP留言本」· JavaScript 代码 · 共 42 行
JS
42 行
function convert(str)
{
var newstr = "";
for(i=0;i<str.length;i++)
{
var ch =str.charAt(i);
switch(ch)
{
case String.fromCharCode(13) : newstr=newstr+"<br>"; break;
case String.fromCharCode(32) : newstr=newstr+" "; break;
case "<" : newstr=newstr+"<"; break;
case ">" : newstr=newstr+">"; break;
case String.fromCharCode(34) : newstr=newstr+"""; break;
case "'" : newstr=newstr+"''"; break;
case "&" : newstr=newstr+"&"; break;
default : newstr+=ch;
}
}
return newstr;
}
//---------revers convert
function reconvert(str)
{
var newstr = "";
newstr = str.replace("<br>",String.fromCharCode(13));
newstr = str.replace(" "," ");
newstr = str.replace("<","<");
newstr = str.replace(">",">");
newstr = str.replace(""",String.fromCharCode(34));
newstr = str.replace("''","'");
newstr = str.replace("&","&");
return newstr;
}
//---------check space
function isSpace(str)
{
for(i=0;i<str.length;i++)
{
if(str.charAt(i) != " ")return false;
}
return true;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?