Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

razor view » character rendered as »

The » character seems to get rendered as » in a razor view. I have tried

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

and

@Html.Raw()

but the problem does not go away. I did not have this issue with ASPX views.

Also, culture is set as

<globalization uiCulture="en" culture="en-US" />
like image 292
sean Avatar asked Jul 17 '12 05:07

sean


1 Answers

I suspect that your .cshtml view/partial containing this character is not saved with the UTF-8 with signature encoding. Also do the same verification for the _Layout. In VS use the Save As with encoding dialog:

enter image description here

Also make sure that you have put the » character as-is in your view. Not coming from a string, XML or a database. If it comes from somewhere else make sure that it is not corrupted already when you are reading it. If this is the case please show the code that is retrieving the string that you are trying to output in the view.

Final remark about your meta tag: if you are using HTML5 use:

<meta charset="utf-8" />
like image 176
Darin Dimitrov Avatar answered Nov 15 '22 09:11

Darin Dimitrov