Mode 1:
A string is displayed on a Web page and does not display the original format, for example, a carriage return is displayed as a space on a Web page, and
the following method can be used to change string to an HTML-recognizable format. Public
static String tohtmlstring (string in) {
stringbuffer out = new StringBuffer ();
for (int i = 0;!= null && i < in.length (); i++) {
char c = in.charat (i);
if (c = = '/')
out.append ("");
else if (c = = '/")
Out.append (" ");
else if (c = = ' < ')
Out.append ("<");
else if (c = = ' > ')
out.append (">");
else if (c = = ' & ')
out.append ("&");
else if (c = = ')
out.append ("");
else if (c = = ' n ')
out.append ("<br/>");
else
Out.append (c);
}
return out.tostring ();
}
Mode 2:
HTMLDocument string2html (String htmlstring)
{
WebBrowser getinfowebbrowser = new WebBrowser ();
Getinfowebbrowser.scripterrorssuppressed = true;
Getinfowebbrowser.documenttext = htmlstring;
HTMLDocument html = getinfowebbrowser.document;
Application.doevents ();
Getinfowebbrowser.dispose ();
return html;
}