Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter FiveGeneral Functions (continued)

DecodeString Function

Overview

The DecodeString function decodes a source string and returns the result either as a string or writes the data to an object.

Syntax/Parameters

Syntax

string = DecodeString ( string source, [dword mode], [handle target] );

Parameters

source

A string containing the encoded data. See Remarks for details.

mode

An optional dword specifying operating mode. See Remarks for details. The mode can be ENCODE_BASE32 or ENCODE_BASE64. The default is ENCODE_BASE64.

target

An optional handle pointing to a Data or Pool Object. When used the returned string will always be empty.

Return Value

Returns a string containing the decoded data or empty if a target was specific or empty on failure. Use the GetLastError and GetLastErrorMessage to retrieve a formatted error code and message.

Note that return strings cannot contain zero bytes (\0) as such programmers are encouraged to check to for an error condition.

Remarks

While DecodeString is meant to process a number of formats, it presently supports Base64.

The result can be directed to a string or to a data object. When directing to a string, the result should not contain binary (specifically /0 bytes). If binary is encountered, the string will be terminated at that point with the last error set to ERROR_FUNCTION_NOT_SUPPORTED with the termination pointer in the low part of the error (and the return value with ERROR_NONE_MASK, 0x00FFFFFF or ~ERROR_MASK to retrieve the terminate point) with the detail message “Warning, contains binary 0 byte(s) at 123”.

If the target is a Pool Object, it can contain zero bytes but retrieve routines must deal with zero terminators.

For Base64, the incoming string must either be line ending complaint or a solid block of Base64 encoding. The general specifications for base 64 are short lines of 76 characters or less (RFC 1421). The function allows for 256 characters. In solid block mode, the Base64 information is encoded as a solid stream without spaces or returns.

If the string is encoded using the ENCODE_ENCODE_LINE_ENDINGS using EncodeString, the “\r” segments must be replaced with actual return codes 0x0D or combination 0x0D 0x0A codes in the source string prior to processing.

Base32 encoding is based on RFC 4648. Base32 expects that the string not contain any formatting such as spaces or returns.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic