开发者

.net HTML Encoding ISO10646 characters, Trade Mark, Euro, etc

I am having a constant series of problems with encoding characters for output in an XML file through .NET. I have a feeling that the problem relates to a setting on th开发者_如何学编程e Response object being used but I'm unable to get anywhere finding the correct setting.

If I do the following:

system.web.httpcontext.current.response.write("€ & ™" & server.HTMLEncode(" € & ™ "))

I get the following output:

€ & ™ € & ™

The question is why are standard ASCII characters encoded, but the extended(?) characters not? Is there some kind of setting I need to give to the server object to tell it to convert characters like Euro/Trade Mark?

One of the bullet points of MSDN's HTMLEncode function page states that:

Any ASCII code character whose code is greater-than or equal to 0x80 is converted to &#, where is the ASCII character value.


You seem to be looking at the documentation for classic ASP server objects.

ASP.NET strings are Unicode based, not ASCII based and the documentation doesn't mention ASCII.

You could ensure ASCII encoding if you use the overload that takes a TextWriter initialized with an Encoding.AsciiEncoding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜