Skip to content

Encoding

Include: Use System\Security.pkg

See Also: DFSEC_Encode, DFSEC_Decode, DFSEC_EncodeUC, DFSEC_DecodeUC, System\URI.pkg wrappers UriEncodeComponent and UriDecodeComponent

Purpose

Encodes and decodes strings, byte-compatible arrays, and pointer-addressed byte ranges.

Constants

C_DFSEC_ENCODING_BASE64 : Base64 using A-Z, a-z, 0-9, +, /, and = padding.

C_DFSEC_ENCODING_BASE32 : Base32 using A-Z and 2-7 with = padding. Decoding accepts uppercase or lowercase letters.

C_DFSEC_ENCODING_HEX : Uppercase hexadecimal text, two characters per byte.

C_DFSEC_ENCODING_URI : URI percent-encoding. Encoding leaves ASCII letters, digits, -, _, ., and ~ unchanged. Decoding converts + to a space and decodes %HH sequences.

DFSEC_ENCODING_FORMAT : Integer-backed DataFlex format type used by the encoding APIs.

Behavior

Empty input returns empty output.

An invalid format raises DFERR_BAD_PARAMETER. The regular encode/decode functions support DataFlex strings and byte-compatible arrays. Other values raise DFERR_BAD_PARAMETER.

Pass valid encoded data for the selected format when decoding. For Hex, provide an even number of hex characters. For Base64 and Base32, include padding when required by the data.

System\URI.pkg provides UriEncodeComponent and UriDecodeComponent as URI component convenience wrappers around the Security URI encoding format.

Example

String sEncoded sDecoded

Get DFSEC_Encode C_DFSEC_ENCODING_BASE64 "DataFlex" to sEncoded
Get DFSEC_Decode C_DFSEC_ENCODING_BASE64 sEncoded to sDecoded