I have a text file with different characters and want to convert each character in HEX values. I am using Encoding.ASCII.GetBytes()
and then converting each byte to hex.
But the result is not correct each time. Some characters does not show their correct hex values and expected. For example the charcter 'î'
should return the expected hex value 8C
according to the provided document, but the code below returns 3F
.
The code which is used is as following:
string myBytes = String.Empty;
string dp = "î";
byte[] bdp = Encoding.ASCII.GetBytes(dp);
foreach (byte b in bdp)
{
myBytes += b.ToString("x") + " ";
}