I have a list of data in a text file, which is written in hex like this:
AE 66 55 78 FF 6A 48 40 CA BC 1B 2C 18 94 28 28
CF EA 02 00 02 51 23 05 0E F2 DD 5A E5 38 48 48
CA BC 1B 2C 18 94 28 40 EE B6 65 87 E3 6A 48 48
..
And I want to convert the values into char in another text file
I have tried this in c#:
private static void OpenFile()
{
ASCIIEncoding ascii = new ASCIIEncoding();
string str = string.Empty;
using (System.IO.BinaryReader br = new System.IO.BinaryReader
(new System.IO.FileStream(
"hexa2.txt",
System.IO.FileMode.Open,
System.IO.FileAccess.Read,
System.IO.FileShare.None), Encoding.UTF8))
using (System.IO.StreamWriter sw = new System.IO.StreamWriter("sms23.txt"))
{
str = @"the path";
Byte[] bytes = ascii.GetBytes(str);
foreach (var value in bytes)
sw.WriteLine("{0:X2}", value);
sw.WriteLine();
String decoded = ascii.GetString(bytes);
sw.WriteLine("Decoded string: '{0}'", decoded);
}
}
I expect that every byte will be converted into char. e.g. "EE" is "î"