views:

1322

answers:

1

How can I escape localized string encoding:

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

is there another way to encode localized strings?

+2  A: 

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 />
Steve Willcock
Hmm - this works fine for me:<%= Html.ActionLink("ÆØÅ", "Details")%>Not sure why it's not working for you, thats odd..
Steve Willcock
Hehe, great, glad you got it working :)
Steve Willcock
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.
tomo