Decodes a character string that was encoded by
Encode.
// Encode an image in base64
Res is string = Encode(fLoadBuffer("MyImage.jpg"), encodeBASE64)
// ...
// Decode the image
DecodedImage is Image = Decode(Res, encodeBASE64)
// Decode a buffer received in an HTTP request
bufRead is Buffer = HTTPResponse.Content
<COMPILE IF ConfigurationUNICODE>
bufResult = Decode(AnsiToUnicode(bufRead), encodeBASE64)
<ELSE>
bufResult = Decode(bufRead, encodeBASE64)
<END>
Syntax
<Result> = Decode(<Element to decode> [, <Encoding/decoding format>])
<Result>: Character string or Buffer
Result of decoding.
<Element to decode>: Character string
Data to decode. This data was encoded by Encode.
Caution: The string to decode must be in the same format as the default strings of the project: ANSI or UNICODE.
<Encoding/decoding format>: Integer constant
Specifies the type of encoding. This parameter must be the same as the one used when encoding. | |
encodeBASE64 (Default value) | BASE 64 format (complies with the RFC 4648 standard). Encoded text contains only printable characters and CRs (Carriage Returns). |
encodeBASE64NoCR | BASE 64 format (complies with RFC 4648 standard) without RCs (Carriage Returns). The encoded text contains printable characters only. |
encodeBASE64URL | BASE 64 URL format (complies with the RFC 4648 standard). The encoded text contains printable characters only. |
encodeBASE85 | BASE 85 format. The encoded text contains printable characters only. |
encodePCS | ASCII format. The encoded text contains printable characters only. |
encodeURLToAnsi | URL format. The encoded text only contains characters allowed in a URL. The decoded text is an ANSI string. This constant corresponds to the encodeURLFromAnsi constant used in Encode. |
encodeURLToUnicode | URL format. The encoded text only contains characters allowed in a URL. The decoded text is a Unicode string. This constant corresponds to the encodeURLFromUnicode constant used in Encode. |
encodeURLToUTF8 | URL format. The encoded text only contains characters allowed in a URL. The decoded text is a UTF-8 string. This constant corresponds to the encodeURLFromUTF8 constant used in Encode. |
encodeUUEncode | UUEncode format. The encoded text contains printable characters only. |
Remarks
Format of character strings to decode
The string to decode must be in the same format as the default strings of the current project configuration: ANSI or UNICODE.
To know or modify the default string format:
- Open the description window of the current configuration: on the "Project" tab, in the "Project configuration" group, click "Current configuration".
- The "Unicode" tab allows you to know which type of character strings is used by default.
Business / UI classification: Business Logic