ENCODE64


9.0

 

The ENCODE64 instruction encodes into strict ASCII strings that can then be written to devices that cannot handle binary data. The instruction using the following format:

 

 

[label]

ENCODE64

{source}{sep}{dest}

 

Where:

label

Optional. A Program Execution Label.

source

Required. A previously defined Character String Variable or Literal variable that is encoded.

sep

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.

dest

Required. A Character String Variable that receives the translated characters.

Flags Affected: EOS

Note the following:

  1. The ENCODE64 instruction implements Base64 encoding as described in RFC2045, sec. 6.8. The main purpose of this instruction is to encode into strict ASCII strings for output to devices that cannot handle binary data.

  2. The logical string of {source} is processed to transfer the translated characters to the {dest} variable.

  3. This instruction translates sets of three (3) eight-bits/byte characters into four (4) six bits/byte characters with ASCII values of A-Z, a-z, '+', and '/'.

  4. The EOS flag is set TRUE if the {source} variable is NULL. In this case, the {dest} variable is also set to NULL.

  5. The OVER flag is set TRUE if the {dest} variable is too small to receive the translated characters as processed from the source logical string. The required size of the {dest} variable can be calculated as follows:

  6.  

         DestLen = ( ( ( SourceLength + 2 ) / 3 ) * 4 )

 

 

See Also: DECODE64, Character String Instructions

 



PL/B Language Reference EDIT ENCRYPT