Hexadecimal string to ascii conversion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmash
    New Member
    • Oct 2007
    • 6

    Hexadecimal string to ascii conversion

    Hello,

    I have a string "00460069006E00 61006C" that is in Hexadecimal that needs to be converted as "Final" which is the translation of Hexadecimal. Do you know how to convert the Hex to readable string?

    Thanks,
    jmash
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    well, first it would be helpful if you split that string up into 2character sections (the hex value).
    Then note that you int.Parse() has an overload that allows hex digits.
    Then you typecast the int as a character and add it to a string.

    For example:
    Code:
    string myhex = "6F";
    int val = int.Parse(myhex, System.Globalization.NumberStyles.AllowHexSpecifier);
    char c = (char)val;
    string normaltext = c.ToString();

    Comment

    Working...