Search code examples
c#winformsansi

ByteViewer Control in Winform, get ANSI value of the given input


There is a ByteViewer Control directly available in the .NET Framework. How do I get the data in a ANSI format from this control and assign to a string variable?

My input will be in hexadecimal form.


Solution

  • You'll have to convert the bytes to a string using the C# Encoding class. I'm assuming ANSI is ISO-8859-1.

    var bytes = byteViewer.GetBytes();
    Encoding encoding = Encoding.GetEncoding("ISO-8859-1");
    string result = encoding.GetString(bytes);