4

これはコードです:

Response.Write("asd1 X : " + HttpUtility.HtmlEncode("×"));
Response.Write("asd2 X : " + HttpUtility.HtmlEncode("✖"));

最初のものは:

asd1 X : × // OK, ENCODED AS HTML ENTITIES

2番目のいいえ、ちょうど✖:

asd2 X : ✖

それはどのような文字ですか?また、ここで試してみると、結果は次のようになります。

asd1 X : ×
asd2 X : ✖

何??なぜこの違い?

4

2 に答える 2

7
于 2012-06-19T16:06:25.500 に答える
2

My best guest is that not all strings has a entity representation. The Heavy multiplication X is just one of the many that don't.

To elaborate Oded's link, HttpUtility.HtmlEncode only encodes characters in ISO 8859-1 (Latin-1). Since the Heavy Multiplication X is out of this range, the function doesn't handle it.

If you try Microsoft.Security.Application.AntiXss.HtmlEncode("✖");, you'll get the HTML entity in ✖.

于 2012-06-19T16:06:58.143 に答える