Czech special characters and using Html.Raw

Topics: General, Localization
Aug 18, 2011 at 2:22 PM
Edited Aug 18, 2011 at 2:36 PM

Hi,

I'm new (and beginner in mvc 3) :) And I am learning...
 I've made some web, everything works fine, but I have one little problem. In Czech we have special characters like this: ě š č ř ž ý á í é. I set lang="cs", charset="utf-8"...
Every characters are display properly in frontend, but when I open Source code of page, some characters are display as &#XXX; where XXX is number as you know :) So menu text in source code look as this:

Pro média ("missing" é)
Výroba elektřiny ("missing" ý) and so on...

On other websites written in PHP or where is used Joomla or some other CMS, there are these special characters in source code OK.

So I have an idea :) I want to use @Html.Raw() for content in ~/Core/Shapes/Document.cshtml or in my layout.cshtml BUT... there is the problem. I trying use something like this:

@Display(Html.Raw(Modul.Body)) OR
@Html.Raw(Display(Modul.Body)) OR

var telo = "@Display(Modul.Body)"
@Html.Raw(telo) OR

var telo = new HtmlString(Display(Modul.Body))
@Html.Raw(telo)

And so on....

I am sure that some of these experiments are absolute nonsense...

But How can I achieve that text in frontpage that see user (maybe "Výroba elektřiny") will be displayed in Source code as "Výroba elektřiny" not as "Výroba elektřiny"? 
Or how can I use Html.Raw in this case?

 

Thanks to everyone :)
And sorry if it is very stupid question :) but I looking for everywhere and nothing found :(

Coordinator
Aug 18, 2011 at 6:36 PM

Actually it's not Orchard specific, and you might have better chances on a Razor or ASP.NET dedicated forum. But be sure if I knew the answer I would have replied ;)

Do you know the origins of the issue ? Is using Html.Raw rendering what you want, but Html.Raw(Display()) not working ?

Aug 19, 2011 at 7:00 AM

No :( When I add <customErrors mode="Off" /> into web.config I get only error 500 internal server error, not what is wrong in code :(

Is using Html.Raw rendering what you want, but Html.Raw(Display()) not working ? /// Yes, this works. But when I add something into brackets, it stop works.
I tried now something like this:

var telo = Modul.Body;
@Html.Raw(Display(telo)) // Error 500

var telo = "Modul.Body";
@Html.Raw(Display(telo)) //  Error 500

only @Html.Raw(Display())  // Ok, without texts and layout :))
as you write yesterday.

Any idea? :)

Thanks

Coordinator
Aug 22, 2011 at 7:56 PM

And Display(telo) works without the Raw around it?

Aug 24, 2011 at 9:45 AM

Yes @Display(telo) works without Raw...

Coordinator
Aug 24, 2011 at 7:13 PM

Weird. All Raw is doing is returning a new HtmlString, and that is just storing the value without manipulating it in any way. The error is probably in Razor. Can you provide the full stack trace for that 500 error?

Aug 25, 2011 at 8:24 AM

Don't understand... :(

I know that razor can has some errors/mistakes.

 

But is there some other solution? Maybe exists some code for this, but only I don't know it :) I think that something must exist because what about Russian websites, or Japan/China..? there are a special characters too...

Thanks

Coordinator
Aug 25, 2011 at 7:26 PM

A good way to test further would be to try the same thing with a string literal:

@("whatever string seems to be the problem")
Coordinator
Aug 25, 2011 at 7:27 PM

Also, having an actual stack trace, as I asked above, would help immensely.

Aug 25, 2011 at 8:48 PM

Oh sorry, I didn't know what means stack trace in cz :D but now I know, tommorow I look into log and write it...

Aug 26, 2011 at 12:33 PM

Hi,

so I look into logs in App_Data and all logs in time when I tried this with html.raw are empty (I tried it today again and log is empty too)... :( in logs where are some lines there is in "long time ago" when I didn't "playing" with html.raw... And into logs on server I have access denied...

Coordinator
Aug 26, 2011 at 6:12 PM

That's weird in itself, but when you are getting those 500 errors, you should also have the stack traces right on the screen, provided your web.config has custom errors set to on (don't leave it on on your production server by the way).

Aug 31, 2011 at 4:37 PM

you should also have the stack traces right on the screen // yes I know, when I set in web.config custom errors I get this screen http://farm4.static.flickr.com/3638/3682579194_ea5803805b_o.jpg not this screen http://dotnetslackers.com/images/articleimages/detail-html-view.png

 

Coordinator
Aug 31, 2011 at 7:01 PM

OK, can you give me a repro with a simple @("something") that I could try?