Altova MapForce 2024 Professional Edition

Returns the character representation of the decimal Unicode value (code) supplied as argument. Tip: To find the Unicode decimal code of a character, you can use the code-from-char function.

mf-func-char-from-code

 

Languages

Built-in, C++, C#, Java, XQuery, XSLT 2.0, XSLT 3.0.

 

Parameters

Name

Description

code

The Unicode value, as a decimal number.

 

Example 1

According to the charts available on the Unicode website (https://www.unicode.org/charts/), the exclamation mark character has the hexadecimal value of 0021. The corresponding value in decimal format is 33. Therefore, supplying 33 as argument to the char-from-code function will return the ! character.

 

Example 2 (Professional and Enterprise editions)

This example shows how to replace special characters in a database with space characters. Consider an SQLite database consisting of a table "Lines" which has two columns: "ID" and "Description".

mf_db_specialchars_01

The goal is to extract each description to a CSV file (one description per line); therefore, a mapping to achieve this goal could look as follows:

mf_db_specialchars_02

However, because each "Description" row in Access contains multiple lines separated by CR/LF characters, the mapping output includes line breaks also, which is not the intended result:

mf_db_specialchars_03

 

To overcome this problem, we are going to add to the mapping the char-from-code and replace functions from the MapForce built-in library. Every description must be processed so that, whenever the characters above are encountered, they should be replaced by a space character.

 

In the Unicode chart (http://www.unicode.org/charts/), the LF and CR characters correspond to hex 0A | dec 10 and hex 0D | dec 13 characters, respectively. Therefore, the mapping has to be modified to convert the decimal Unicode values 13 and 10 to a string, so as to allow further processing by the replace function.

mf_db_specialchars_04

If you preview the mapping now, notice that the CR/LF characters within each database field have been replaced by a space.

mf_db_specialchars_05

 

© 2017-2023 Altova GmbH