给html中的特处符号编码---C#

    public String HtmlEncode(String txt)
    {
        txt = replace(txt, "&", "&");
        txt = replace(txt, "\"", """);
        txt = replace(txt, "<", "&lt;");
        txt = replace(txt, ">", "&gt;");
        txt = replace(txt, " ", "&nbsp;");
        return txt;
    }

你可能感兴趣的:(html)