I want characters like \'ø\' to be printed directly, but in the source \'ø\' shows up as ø
If the output goes through Html.Encode()
You could try to create output with <%=
instead of html encoded <%:
(I post this after your positive comment to my comment)
AFAIK this is not possible unless you roll your own custom HTML encoding routine (which I absolutely would recommend you against).
The resulting HTML is correct and the character is properly displayed on the client browser. HTML is meant to be read by programs (web browsers) in order to present it to a human readable form, not by humans.
<li><a href="/Tag/Stovletter">Støvletter</a></li>
is a perfectly valid HTML that will be displayed like this on the client browser:
This might not be the answer you are looking for but it is nevertheless interesting.
If you look at the HttpEncoder
source code it makes provision for custom HtmlEncoders
to be used instead of the default WebUtility.HtmlEncode
I have played around and found the HtmlEncoder called AntiXSS from Microsoft encodes these characters correctly.
I installed it using Nuget:
PM> Install-Package AntiXSS
And then updated my web.config
as such:
<system.web>
<httpRuntime encoderType="Microsoft.Security.Application.AntiXssEncoder,
AntiXssLibrary" />
....
</system.web>
Both normal output and Html.ActionLinks seem to work.