appsettings with special characters in .NET Core

JSON mandates UTF-8 as the file encoding. Your file is most likely saved in some other encoding, possibly Codepage 1252. Make sure you save the file as UTF-8 and your characters will work.

Different tools handle this differently.

For Notepad there’s an Encoding selection in the Save dialog:

enter image description here

Visual Studio has a Save with Encoding option in the Save dialog:

enter image description here

You could also write a small program or script to do the conversion, e.g. the following PowerShell pipeline:

(Get-Content appsettings.json) | Set-Content -Encoding Utf8 appsettings.json

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)