Home > front end >  Problem with accentued char when reading appsettings.json with builder
Problem with accentued char when reading appsettings.json with builder

Time:09-26

I am reading the configuration file appsettings.json with the builder;

    var builder = new ConfigurationBuilder().SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
                                            .AddJsonFile(Path.Combine(Helper.jsonpath, "appsettings.json"));
    Helper.config = builder.Build();
    //same result : P�le emploi instead of Pôle emploi
    var tt = Helper.config.GetSection("partooApi:types:APE").GetValue<string>("title");
    var ttt = Helper.config["partooApi:types:APE:title"];
    var tttt = Helper.config.GetSection("partooApi:types:APE:title").Get<string>();

i have the result P�le emploi instead of Pôle emploi

my appsettings.json has nothing special:

"partooApi": {
  "types": {
      "APE": {
        "title": "Pôle emploi",
        "grpname": "Agences",
        "grpid": 10661
      }
     :

I dont see options to encode, am i missing something in my code?

CodePudding user response:

Have you checked if appsettings.json is saved as UTF-8 encoding?

  • Related