「Java入門」特殊文字をHTML用に変換するサンプル

Javaコード:
static public string TagToHtmlCode(string str)
{
str = str.Replace(“&", “&");
str = str.Replace(“<“, “&lt;");
str = str.Replace(“>", “&gt");
str = str.Replace(“'", “"");
str = str.Replace(“*", “");
str = str.Replace(“\n", “<br/>");
str = str.Replace(“\r\n", “<br/>");
str = str.Replace(“?","");
}

Java

Posted by arkgame