I am seeing an unexpected character (?) in the output of Encoding.ASCII.GetBytes method.
So I am doing the following:
var stringBytes = Encoding.ASCII.GetBytes(myString);
Where myString is:
{
"$id": "1",
"Note": "<p><span style=\"font-family: "Courier New";\">aaaa</span>
<br></p>"
}
Now right after if I do:
var myString1 = System.Text.Encoding.Default.GetString(stringBytes)
Then myString1 is returned as:
{
"$id": "1",
"Note": "<p><span style=\"font-family: "Courier New";\">?
aaaa</span><br></p>"
}
Note how the aaaa is transformed to ?aaaa in the last operation?
Can someone please tell me what I missing here? Thank you.
Encoding.Defaultto decode a string encoded withEncoding.ASCII? Even if your system did default toEncoding.ASCIIforEncoding.Default, it seems like a bad idea in general. *On .NET CoreEncoding.Defaultis alwaysEncoding.UTF8.