Forum Discussion

MDPF52_180608's avatar
MDPF52_180608
Icon for Nimbostratus rankNimbostratus
Mar 02, 2015

Convert Binary to ASCII

Hello DevCentral Community ,

 

How i can convert an HTTP payload from the binary format to the ascii format in order to search certain string values in it ?

 

Is this correct ?

 

set test [HTTP::payload] binary scan $test H* hex set ascii [binary format A* $hex]

 

Thanks in advance,

 

M.

 

4 Replies

  • The issue is also about the encoding that the http payload is in. UTF-8 is not ASCII, so you would need to ensure that the binary you would like to convert is in fact ascii.

     

    That being said I would reference the tcl wiki page for binary, they have several examples. http://wiki.tcl.tk/1181

     

    • MDPF52_180608's avatar
      MDPF52_180608
      Icon for Nimbostratus rankNimbostratus
      Thank you Brian! I want to have the plain text of the response page so which is the correct method in order to have this output ? THanks in advance, Matteo
    • MDPF52_180608's avatar
      MDPF52_180608
      Icon for Nimbostratus rankNimbostratus
      Thank you, so i have to scan it and then convert it to hex and then convert it to ASCII ? THanks