Special characters in Razor template not being encoded correctly

醉酒当歌 提交于 2019-12-04 17:47:04

问题


I make some test with ASP.NET Core MVC. I am trying to display special character like çùé.

But it is displayed as �.

Exemple :

Create new view and put :

<div>àçù</div>

By default, the .cshtml file is encoded in "UTF-16". The charset in HTTP response header is "UTF-8". In _layout, the <head> contains the <meta charset="utf-8" /> tag.

To resolve the problem, I can convert all .cshtml file to uft-8.

What's the correct way to manage encodage in ASP MVC Core?

Edit :

Visual Studio 2017 RC create .cshtml file in 'utf-8', but the scaffolding create the .cshtml file in 'ISO 8851-1'.

Can I explain to scaffolding I want .cshtml file in 'UTF-8'?


回答1:


I solved it by simply opening the file with problems, confirming it was encoded as ANSI, converted it to UTF-8 and everything run smooth again. I also created a post for this, so both seem duplicated right now. MVC .net core is not displaying special characters correctly



来源:https://stackoverflow.com/questions/41882276/special-characters-in-razor-template-not-being-encoded-correctly

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