0

How can I escape localized string encoding:

<%= Html.Encode("ÆØÅ") %> from rendering  &#198;&#216;&#197;

is there another way to encode localized strings?

1 Answer 1

2

That's being encoded twice - are you using this in a HtmlHelper call?

// this will display&#198;&#216;&#197; as Html.TextBox encodes the
// value passed to it so it's encoded twice in this line
<%=Html.TextBox("sdfsdf", Html.Encode("ÆØÅ"))%><br />

// this will display ÆØÅ
<%= Html.Encode("ÆØÅ") %><br />

// As will this
<%=Html.TextBox("sdfsdf", "ÆØÅ")%><br />
Sign up to request clarification or add additional context in comments.

2 Comments

Hmm - this works fine for me: <%= Html.ActionLink("ÆØÅ", "Details")%> Not sure why it's not working for you, thats odd..
BTW: there's bug in MVC View file template. It's saved without BOM, so if you plan to use it as UTF-8 then I recommend to save as UTF-8 with BOM. Otherwise it will use system default encoding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.