Display non English character in text box

I want to display some non-English characters in a text box.

I'm trying with

$("#txtSearch").val('<%:Html.Raw(ViewBag.my_search)%>') 

It should display "2100 - København Ø", but it displays "2100 - København à ~".

my controller reads this value from the cookie and assigns it to the ViewBag. In the controller I have

 ViewBag.my_search = cookie.Value // here it is assigning the right danish word but when it displays inside the input box, it just displays wrong. 

any idea how to solve this problem?

EDIT:

Well, it works well on my local computer, but when I host it on some kind of remote hosting provider, it does not work well.

0
source share
1 answer

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> not a good way to customize the encoding of a page because it is overridden with a real HTTP header. Therefore, if the remote hosting provider sends a content type header, it will be ignored.

Your data is correct utf-8, so good. All you need to do is set the header of the http type of the content so that the browser reads it as utf-8 and not windows-1252.

You can customize your individual page to send a header using

 <%@ Page RequestEncoding="utf-8" ResponseEncoding="utf-8" %> 

Or you can install it in Web.config globally:

 <configuration> <system.web> <globalization requestEncoding="utf-8" responseEncoding="utf-8" /> </system.web> </configuration> 
+1
source

All Articles