I have some code to dump strings to stdout to check their encoding, it looks like this:
private void DumpString(string s)
{
System.Console.Write("{0}: ", s);
foreach (byte b in s)
{
System.Console.Write("{0}({1}) ", (char)b, b.ToString("x2"));
}
System.Console.WriteLine();
}
Consider two strings, each of which appear as "ë", but with different encodings. DumpString will produce the following output:
ë: e(65)(08)
ë: ë(eb)
The code looks like this:
DumpString(string1);
DumpString(string2);
How can I convert string2, using the System.Text.Encoding, to be byte equivalent to string1.