@EncodeStringToBytes

Parent Previous Next

@EncodeStringToBytes.

Converts a text string into a blob - going from the Unicode format of the internal string type to a specified codepage of the blob content.

A special feature is the possibility of doing base64 conversions.


Syntax.


 @EncodeStringToBytes(String text; Integer toCodepage) : Blob

 


Arguments:


Example:


 String fileText := "This is my file text";


 Integer cpUTF8 := 65001; //the utf8 codepage;

 Blob fileBytes := @EncodeStringToBytes(fileText, cpUTF8);


 Boolean append := False;

 @FileWriteBytes("c:\test\file_in_utf8.txt", append, fileBytes);



Base64.

If the text string is perceived to contain a base64 string, it can be converted from base64 format to the represented byte sequence. By setting the codepage to -64 (which is not a real codepage value) a special feature is invoked that performs the base64 conversion. Please read the more elaborated explanation found here which describes the opposite operation in detail.