qacafe - ip test solutions
Knowledge Base > Test API > What is ascii hex format?

What is ascii hex format?

In some cases, CDRouter requires data in test cases or the configuration file to be in ascii hex format. This refers to string data that is converted into ascii format and the ascii values are shown in hexademial.

For example, the string "qacafe" maps to the ascii hex value of 71 61 63 61 66 65. If you are entering ascii hex data in a configuration file or script, you would enter the data without any spaces. For example, 716163616665.

If you are working with a Tcl test case, you can convert your string data into ascii hex using the pktsrc text2ascii command. The following code snippet gives an example:

   set str "This is a string"

   # -- convert from text to ascii-hex
   set hex [ pktsrc text2ascii $str ]
   puts $hex

   # -- convert back to text from ascii-hex
   set text [ pktsrc ascii2text $hex ]
   puts $text

If you are not writing a script, you can also visit http://www.easycalculation.com/ascii-hex.php to convert strings to ascii hex.