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.

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

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

I was looking into this more and I think you might want to try is the scan command. It should do the conversion and search function for you, just specify the input format etc..

iRules 101 - 16 - Parsing Strings with the TCL Scan Command

Thank you, so i have to scan it and then convert it to hex and then convert it to ASCII ? THanks