Altova MapForce 2022 Enterprise Edition

The charset-decode function takes as input binary data encoded as Base64 text. It decodes data according to the specified character set (for example, "utf-8") and returns the resulting string value. If you need to encode binary data as Base64 text, use the charset-encode function.












The binary data as Base64 text.



The character set used for encoding (for example, "utf-8").



Optional argument that specifies how processing should continue when errors are encountered. Valid values:


true - End processing with an exception on the invalid character.

false - Continue processing, and replace invalid characters with the replacement character ic_utf8_replacement_char.


The default value is true.



Let's suppose that you would like to decode binary data originating from the following source XML file. Notice that the message element contains binary data encoded as Base64 text.


<?xml version="1.0" encoding="UTF-8"?>
<message xsi:noNamespaceSchemaLocation="message.xsd" xmlns:xsi="">TG9yZW0gaXBzdW0=</message>


The data type of the message element is xs:base64Binary, as illustrated by the schema:


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="">
  <xs:element name="message" type="xs:base64Binary"/>


A mapping that decodes the message above looks as follows:


The mapping in this example outputs the text "Lorem ipsum".


A mapping can also process text or XML files encoded as Base64 data, with the help of a MapForce serialization component. For example, the mapping illustrated below has an input parameter which expects Base64 text data. Assuming that the Base64 data was created from an XML file as shown in the charset-encode example, you can recreate the original XML file as shown in the mapping below:


In this mapping, the error-abort argument gets a false value, which was produced with the help of the boolean built-in function. This ensures that processing will continue even if invalid characters are encountered. The string result of the function is then passed to an XML parsing component which converts it to an XML file. Note that, in order for XML parsing to be possible, you must have the XSD schema file. For more information, see Parsing and Serializing Strings.

© 2016-2022 Altova GmbH