Modifier

Partager via


TextEncoding Property

Version: Available or changed with runtime version 1.0.

Specifies the text encoding format to use when you use an XmlPort to export or import data as text.

Applies to

  • Xml Port

Property value

Value Available or changed with Description
MSDOS runtime version 1.0 Use MS-DOS encoding format. It is the default value.
UTF8 runtime version 1.0 Use UTF-8 encoding format.
UTF16 runtime version 1.0 Use UTF-16 encoding format.
WINDOWS runtime version 1.0 Use Windows encoding format.

For more information, see [File Handling and Text Encoding.

Syntax

TextEncoding = Windows;

Remarks

The TextEncoding property is only available when the Format property is set to Fixed Text or Variable Text.

File Handling and Text Encoding is the process of transforming bytes of data into readable characters for users of a system or program. There are several industry File Handling and Text Encoding formats and different systems support different formats. Internally, Dynamics 365 Business Central uses Unicode encoding. For exporting and importing data with an XMLport, Dynamics 365 Business Central supports MS-DOS, UTF-8, UTF-16, and Windows encoding formats.

The Text data type in AL uses the in AL uses UTF-16 encoding, the same encoding as .NET strings. For more information, see String class (.NET).

You should set the TextEncoding property to the encoding format that is compatible with the system or program that you will be exporting to or importing from. The following sections describe the available File Handling and Text Encoding formats.

Tip

You can also set the TextEncoding property in AL code using the TextEncoding Method . For example, if your XMLport can import or export different formats based on certain conditions, you can change the encoding on the fly depending on the conditions. For example, you can write code such as one of the following:

currXMLport.TextEncoding := TextEncoding::Windows;
currXMLport.TextEncoding(TextEncoding::Windows);

Example

The following code example illustrates how you can set the encoding during run time.

...  
      case MyDefinitionTable."File Encoding" of  
        MyDefinitionTable."File Encoding"::"MS-DOS":  
          currXMLport.TextEncoding(TextEncoding::MSDos);  
        MyDefinitionTable."File Encoding"::"UTF-8":  
          currXMLport.TextEncoding(TextEncoding::UTF8);  
        MyDefinitionTable."File Encoding"::"UTF-16":  
          currXMLport.TextEncoding(TextEncoding::UTF16);  
        MyDefinitionTable."File Encoding"::WINDOWS:  
          currXMLport.TextEncoding(TextEncoding::Windows);  
...  

The code example is based on XMLport 1220 in the CRONUS International Ltd. demonstration database. The table, MyDefinitionTable, has a field, File Encoding, that specifies the encoding for this part of an import.

Properties
Format Property (XMLports)
File Handling and Text Encoding