FAQ : Frequently Asked Questions
FAQ Table of contents
blue line
37. Q:  For some reasons, in a CGI I need to retrieve the query string. That I do retrieving the environment variable QUERY_STRING.
The point here is that the query string may contain "escaped sequences" such as:
   "%24" instead of "$"
   "%5C" instead of "\"
   "%26" instead of "&"
   "%2B" instead of "+"
   etc.
How can I convert the escaped sequences to their corresponding characters and the other way around?

A:  An "escaped sequence" is the ASCII hexadecimal representation of a character preceeded by character %.

  1. The CGIDEV2 subprocedure that converts a character string to a character string containing ASCII escaped characters wherever necessary, is urlEscSeq().
  2. The CGIDEV2 subprocedure that converts a characters string containing ASCII escaped characters to a "normal" character string, is urlUnescSeq().

Javascript functions escape() and unescape() cal also be used to "escape" or "unescape" ASCII characters. Examples:
escape('&') results to %26
unescape('%26') results to character &

blue line