{"title":"TextEncoding Property","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/properties/devenv-textencoding-property/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-textencoding-property, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-textencoding-property","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Specifies the text encoding format to use when you use an XmlPort to export or import data as text.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Applies to","slug":"applies-to","at":160,"chars":24},{"level":2,"title":"Property value","slug":"property-value","at":184,"chars":353},{"level":2,"title":"Syntax","slug":"syntax","at":537,"chars":44},{"level":2,"title":"Remarks","slug":"remarks","at":581,"chars":1552},{"level":2,"title":"Example","slug":"example","at":2133,"chars":814},{"level":2,"title":"Related information","slug":"related-information","at":2947,"chars":135}],"text":"> Version: _Available or changed with runtime version 1.0._\nSpecifies the text encoding format to use when you use an XmlPort to export or import data as text.\n## Applies to\n Xml Port\n## Property value\nValue|Available or changed with|Description\nMSDOS|runtime version 1.0|Use MS-DOS encoding. It is the default value.\nUTF8|runtime version 1.0|Use UTF-8 encoding with BOM (Binary Order Mark).\nUTF16|runtime version 1.0|Use UTF-16 encoding.\nWINDOWS|runtime version 1.0|Use Windows encoding.\nSee [../devenv-file-handling-and-text-encoding.\n## Syntax\n```al\nTextEncoding = Windows;\n```\n## Remarks\nThe TextEncoding property is only available when the Format property is set to Fixed Text or Variable Text.\n../devenv-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 ../devenv-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.\nThe ../methods-auto/text/text-data-type in AL uses the in AL uses UTF-16 encoding, the same encoding as .NET strings. See String class (.NET)<https://learn.microsoft.com/dotnet/api/system.string?view=net-8.0&preserve-view=true>.\nYou 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 ../devenv-file-handling-and-text-encoding formats.\n> TIP\n> You can also set the TextEncoding property in AL code using the ../methods-auto/xmlport/xmlportinstance-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:\n> `currXMLport.TextEncoding := TextEncoding::Windows;`\n> `currXMLport.TextEncoding(TextEncoding::Windows);`\n## Example\nThe following code example illustrates how you can set the encoding during run time.\n```al\n...\n      case MyDefinitionTable.\"File Encoding\" of\n        MyDefinitionTable.\"File Encoding\"::\"MS-DOS\":\n          currXMLport.TextEncoding(TextEncoding::MSDos);\n        MyDefinitionTable.\"File Encoding\"::\"UTF-8\":\n          currXMLport.TextEncoding(TextEncoding::UTF8);\n        MyDefinitionTable.\"File Encoding\"::\"UTF-16\":\n          currXMLport.TextEncoding(TextEncoding::UTF16);\n        MyDefinitionTable.\"File Encoding\"::WINDOWS:\n          currXMLport.TextEncoding(TextEncoding::Windows);\n...\n```\nThe 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.\n## Related information\ndevenv-properties\nFormat Property \\(XMLports\\)<devenv-format-property>\n../devenv-file-handling-and-text-encoding"}