ASP.NET MVC 3 jquery : French accent characters are showing as #233 characters on screen

时光总嘲笑我的痴心妄想 提交于 2020-01-03 08:09:29

问题


I have ASP.NET MVC 3 application having resource files in english and french. A text 'Sélectionner la pharmacie' is stored in a french resource file.

When the value is read from resource files with razor syntax, it shows 'S#233;lectionner la pharmacie' instead of 'Sélectionner la pharmacie'.

e.g.
@MyResources.Strings_Resources.lbl_SelectPharmacy

Is there a way I can make it show the french accent characters ?


回答1:


I suspect that your text is already encoded and razor is trying to encode it again (it encodes all outputs)

Try with

@Html.Raw(MyResources.Strings_Resources.lbl_SelectPharmacy)



回答2:


First check your master page, you have set UTF-8

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


<system.web>
    <globalization enableclientbasedculture="true" uiculture="auto" culture="auto">

    <!-- Use above or below <globalization> line, based on your site -->

    <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8"/>
</system.web>

If you have set this already then try below setup:-

<asp:Label Text="<%$ Resources:Strings, MyGlobalResource %>" runat="server" />
<asp:Label Text="<%$ Resources:MyLocalResource %>" runat="server" />


<%= HttpContext.Current.GetLocalResourceString("~/YOURASPXPAGE", "MyLocalResource", CultureInfo.CurrentUICulture) %>

Refer this URL for more info:-

  1. ASP.NET MVC 3 Internationalization
  2. ASP.NET MVC - Localization Helpers


来源:https://stackoverflow.com/questions/8180123/asp-net-mvc-3-jquery-french-accent-characters-are-showing-as-233-characters-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!