When I use the <%=...%> syntax and pass in a string with non-ascii characters, the string is decoded and outputed as ASCII. For example: <%="é"%> outputs é.
How can I make the views output the encoded characters instead?
Why do you want to HTML encode? If your page is utf-8 there should be no problem. But if you want to HTML encode you could use <%: in ASP.NET 4.0:
<%: "é" %>
and:
<%= HttpUtility.HtmlEncode("é") %>
in older versions.
Personally I would recommend you to set the requestEncoding and responseEncoding to utf-8 in the <globalization> element in your web.config and put a <meta charset="utf-8" /> (HTML5) tag in the head section of your master page and you should be fine.
var jsVar = <%= new JavaScriptSerializer().Serialize(SomeObject) %>;. This will ensure safe encoding of everything and you could also pass entire object graphs to javascript.var jsVar = "é";. You should not be html encoding it.