I am trying to convert Hex string to ASCII in c# using visual studio community 2017. My Hex string looks like below
070196000008220031CE4745542073776964FD48
when i convert it into ASCII it looks like below
my confusion is why it is showing ASCII "\a" for hex "07"?? it should be . ASCII value for hex "01" should be but it showing "\u0001". It is same for ASCII control characters and extended ASCII charecters.
Can someone explain please! Am i missing anything and how to get like that.
The code i am using to convert hextoascii
public string ConvertHextoASCII(String hexString)
{
try
{
string ascii = string.Empty;
for (int i = 0; i < hexString.Length; i += 2)
{
String hs = string.Empty;
hs = hexString.Substring(i, 2);
int decval = System.Convert.ToInt32(hs, 16);
char character = System.Convert.ToChar(decval);
ascii += character;
}
return ascii;
}
catch (Exception ex) { Console.WriteLine(ex.Message); }
return string.Empty;
}
Thanks in advance.