StringTools

StringTools object provides several utility methods for encoding and decoding strings. For example, you can use a StringTools object to Base64-encode a chunk of data, or decode a UTF-8 encoded message header.

 

You can obtain a StringTools object using the DOpusFactory.StringTools method.

 

Method Name

Arguments

Return Type

Description

Decode

<Blob:source> or <string:source>

<string:format>

string or

Blob 

Decodes an encoded string or data.

You can provide either a Blob object or a string as the source to decode. Depending on the value of the format argument, either a string or a Blob is returned.

If format is specified as "base64" the source will be Base64-decoded, and a Blob is returned.

If format is specified as "quoted" the source will be Quoted-printable-decoded, and a Blob is returned.

If format is specified as "auto" or not supplied, special handling is invoked to decode a MIME-encoded email subject (e.g. one beginning with =?), and a string is returned.

Otherwise, format must be set to a valid code-page name (e.g. "utf-8", "gb2312" etc.), or a Windows code-page ID (e.g. 936, 65001). The source will be decoded using the specified code-page and a string is returned.

Encode

<Blob:source> or <string:source>

<string:format>

string or

Blob 

Encodes a string or data.

You can provide either a Blob object or a string as the source to decode. Depending on the value of the format argument, either a string or a Blob is returned.

If format is specified as "base64" the source will be Base64-encoded, and a string is returned.

If format is specified as "quoted" the source will be Quoted-printable-encoded, and a string is returned.

Otherwise, format must be set to a valid code-page name (e.g. "utf-8", "gb2312" etc.), or a Windows code-page ID (e.g. 936, 65001). The source will be encoded using the specified code-page and a Blob is returned.