Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special characters in Razor template not being encoded correctly

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'?

like image 312
vernou Avatar asked Jan 26 '17 20:01

vernou


1 Answers

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

like image 77
Ricker Silva Avatar answered Nov 16 '22 01:11

Ricker Silva