//Last modify time:2003-8-31
//Method: public String toHTML(String old_string)
class toHTML
{
public String toHTML(String sStr)
{
if (sStr == null||sStr.equals(""))
{
return sStr;
}
String sTmp = new String();
int i = 0;
while (i <= sStr.length()-1)
{
if (sStr.charAt(i) == '\n')
{
sTmp = sTmp.concat("<br>");
}
else if(sStr.charAt(i) == ' ')
{
sTmp = sTmp.concat(" ");
}
else if(sStr.charAt(i) == '<')
{
sTmp = sTmp.concat("<");
}
else if(sStr.charAt(i) == '>')
{
sTmp = sTmp.concat(">");
}
else if(sStr.charAt(i) == 34) //34为双引号
{
sTmp = sTmp.concat(""");
}
else if(sStr.charAt(i) == 39) //若为单引号则用两个单引号代替
{
sTmp = sTmp.concat("''");
}
else
{
sTmp = sTmp.concat(sStr.substring(i,i+1));
}
i++;
}
return sTmp;
}
}
//-----------End-----------
评论 {{userinfo.comments}}
{{child.content}}
{{question.question}}
提交