0

i am using asp.net mvc 5. Periodically when displaying text (russian language) in the browser window, in some words one letter is replaced with two question marks, like this (Дмитр��й). Logic appearance of this bug can not understand it, appears on a random page, and regardless of whether the text is taken from the database or hand written in code view. What could be the problem and how it can be solved?

ps Sorry for my bad English

manst
  • 1
  • 1
  • 2

1 Answers1

0

I beliave you have same issue as here

so

Several solutions exist :

put in your Web.config. But your may comme with other problems, and your application won't be standard anymore (it will not work with languages like japanese) ... And anyway, I prefer using UTF-8 !

go to about:config in Firefox and set the value of network.standard-url.encode-query-utf8 to true. It will now work for you (Firefox will encode all your url with utf-8). But not for anybody else ...

The least worst solution I could come with was to handle this with code. If the default decoding didn't work, we reparse QueryString with iso8859-1 :

string query = Request.QueryString["search"];
if (query.Contains("%ufffd"))
    query = HttpUtility.ParseQueryString(Request.Url.Query, Encoding.GetEncoding("iso-8859-1"))["search"];
query = HttpUtility.UrlDecode(query);
Community
  • 1
  • 1
teo van kot
  • 12,350
  • 10
  • 38
  • 70
  • I have the error in text page. If add white spaces in the text, two question marks can shift to another word or in general will disappear. – manst Nov 12 '14 at 14:13
  • can you provide `View` code and `ViewModel` code that definitely have this bug? – teo van kot Nov 12 '14 at 15:05