Search code examples
visual-studioasp.net-coreasp.net-core-mvcvisual-studio-2022.net-8.0

ASP.NET Core 8.0 MVC : encoding issue in js files


I created ASP.NET Core 8.0 MVC web app. I have language config file for datatables like this:

var tr_lang = {
    "emptyTable": "Tabloda herhangi bir veri mevcut değil",
    "info": "_TOTAL_ kayıttan _START_ - _END_ arasındaki kayıtlar gösteriliyor",
    ...
}

On the client side and developer tools, I see this file as below

   var tr_lang = {
       "emptyTable": "Tabloda herhangi bir veri mevcut de�il",
       "info": "_TOTAL_ kay�ttan _START_ - _END_ aras�ndaki kay�tlar g�steriliyor",
   }

And one of my script file there is line like this.

console.log("Parametre Kategori kayıt");

In client side I see result as

Parametre Kategori kay�t

There is a encoding problem with Turkish characters. How can I solve this?

P.S. : Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.9.6


Solution

  • I solved the problem.

    The problem was with Visual Studio itself rather than ASP.NET Core 8.0. Select the Encoding option in "Advanced Save Options" under the "File" menu.

    I translated it to Turkish (Windows) - Codapage 1254 -> Unicode (UTF-8 with signature) - Codepage 65001.

    If you don't see the "Advanced Save Options" option under the "File" menu, take a look at this.