CGIDecode

Command groupFlag affectedReversibleExecute on clientPlatform(s)
External commandsYESNONOAll

Syntax

CGIDecode
 
(stream[,mapplustospace 
{Default kTrue}
,utf8 
{Default kFalse}
])
 
Returns 
decoded-stream

Description

Note: The flag is set according to whether Omnis was able to make a call to this external command.

This Web command is multi-threaded,allowing another thread to execute in the multi-threaded server while it runs. Note that the same socket cannot safely be used concurrently by more than one thread.

You use CGIDecode to turn CGI-encoded text back into its original form. It is the inverse of CGIEncode.

When a client uses HTTP to invoke a script on a WEB server, it uses the CGI encoded format to pass the arguments to the server. This avoids any ambiguity between the characters in the argument names and values, and the characters used to delimit URLs, and the argument names and values.

stream is an Omnis Character or Binary field containing the information to decode.

MapPlusToSpace is a Boolean value. When kTrue, in addition to performing a standard CGI decode operation, the command maps all instances of the ‘+’ character in the input stream, to the space character.

UTF8 is a Boolean value. When kTrue, the characters are treated as UTF-8 encoded data meaning that the stream is first decoded and then converted from UTF-8 to character.

DecodedStream is an Omnis Character or Binary field that receives the resulting CGI-decoded representation of the stream argument.

Note: The HTTPHeader, HTTPParse and HTTPPost commands automatically perform CGI encoding or decoding, as appropriate.

Example

Calculate
 
lStream
 as 
'Name: Charlie Malone,Company: Omnis Software Ltd'

CGIEncode
 
(
lStream
)
 
Returns 
lEncodedStream

 
CGIDecode
 
(
lEncodedStream
)
 
Returns 
lDecodedStream

# lDecodedStream now contains the following:

# Name: Charlie Malone,Company: Omnis Software Ltd

 
Calculate
 
lStream
 as 
'Name: Charlie Malone+Friend,Company: Omnis Software Ltd'

CGIEncode
 
(
lStream
)
 
Returns 
lEncodedStream

 
CGIDecode
 
(
lEncodedStream
,
kFalse
)
 
Returns 
lDecodedStream

# lDecodedStream now contains the following:

# Name: Charlie Malone+Friend,Company: Omnis Software Ltd

 
CGIDecode
 
(
lEncodedStream
)
 
Returns 
lDecodedStream

# lDecodedStream now contains the following:

# Name: Charlie Malone Friend,Company: Omnis Software Ltd

# Note the + has been turned into a space character