How to convert Hex -> Dec -> Char
-
I need to convert data from hex to Dec and dec to Char Kindly let me know how can i do that. The confusion is if i need to change the data If i provide Input as a string to the text box 3F 50 52 40 -> 63 80 82 64 -> ? P R @
You can use an overload of the ToString method to specify the number format to show.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
I need to convert data from hex to Dec and dec to Char Kindly let me know how can i do that. The confusion is if i need to change the data If i provide Input as a string to the text box 3F 50 52 40 -> 63 80 82 64 -> ? P R @
Look up Byte Coversions in the MSDN index, you will see the following example;
Dim MyString As String = "Encoding String."
Dim AE As New ASCIIEncoding()
Dim ByteArray As Byte() = AE.GetBytes(MyString)
Dim x as Integer
For x = 0 To ByteArray.Length - 1
Console.Write("{0} ", ByteArray(x))
NextThat should get you started.
-
I need to convert data from hex to Dec and dec to Char Kindly let me know how can i do that. The confusion is if i need to change the data If i provide Input as a string to the text box 3F 50 52 40 -> 63 80 82 64 -> ? P R @
Hi, your question isn't clear. Maybe what you want is: "I have a string with hex byte values, and I want to convert it to a string holding the ASCII-equivalent characters". If so, you need: - a way to split the input string in substrings that each represent a single byte (e.g. use string.split to split on spaces) - a loop to iterate over each substring - byte.TryParse(...,NumberStyles.Hexadecimal) to convert this to a byte array - Encoding.ASCII.GetString to convert to the result - optionally insert spaces to separate the characters :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages