HttpUtility.HtmlEncode doesn't encode everything

后端 未结 7 958
南方客
南方客 2020-12-16 13:45

I am interacting with a web server using a desktop client program in C# and .Net 3.5. I am using Fiddler to see what traffic the web browser sends, and emulate that. Sadly t

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-16 14:16

    The return value type of HtmlEncode is a string, which is of Unicode and hence has not need to encode these characters.

    If the encoding of your output stream is not compatible with these characters then use HtmlEncode like this:-

     HttpUtility.HtmlEncode(outgoingString, Response.Output);
    

    HtmlEncode with then escape the characters appropriately.

提交回复
热议问题