'Keep special characters in File When i save it

I have a file that contains some HTML code. I am trying to load this data into a C# Console app and transfer it into a JSON file to upload somewhere. When loading the file i am losing some of the encoding immediately when bringing the data in.

Example data

<li>Comfort Range: -60°F to 30°F / -50°C to -1°C</li>

Basic read file

//Load the file
String HTML_File = File.ReadAllText(location);
//Output the file to see the text
Console.WriteLine(HTML_File);

Console Output

<li>Comfort Range: -60??F to 30?F / -50?C to -1?C</li>

After i split the data how I need to, I than save the class to a JSON File

File.WriteAllText(OutputPath,JsonConvert.SerializeObject(HTMLDATA));

JSON file Data

<li>Comfort Range: -60�F to 30�F / -50�C to -1�C</li>

How can i go about loading this data and converting it to JSON without losing the encoding? I am still pretty new when it comes to encoding like this.

@JeremyLakeman helped me solve this, thank you sir!! When reading the text into the utility i needed to set the Encoding but not by the default ones.

File.WriteAllText(OutputPath,JsonConvert.SerializeObject(HTMLDATA), Encoding.GetEncoding("iso-8859-1"));


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source