{"title":"File handling and text encoding","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-file-handling-and-text-encoding/","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/devenv-file-handling-and-text-encoding, 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/devenv-file-handling-and-text-encoding","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":"Understand how files are handled and text is encoded in Business Central.","date":"2025-05-21","meta":{"topic":"concept-article"},"outline":[{"level":2,"title":"Text encoding","slug":"text-encoding","at":732,"chars":511},{"level":2,"title":"Encoding formats","slug":"encoding-formats","at":1243,"chars":4725},{"level":3,"title":"MS-DOS encoding format","slug":"ms-dos-encoding-format","at":2500,"chars":824},{"level":3,"title":"UTF-8 encoding format","slug":"utf-8-encoding-format","at":3324,"chars":688},{"level":3,"title":"UTF-16 encoding format","slug":"utf-16-encoding-format","at":4012,"chars":1123},{"level":3,"title":"Windows format","slug":"windows-format","at":5135,"chars":833},{"level":2,"title":"Related information","slug":"related-information","at":5968,"chars":133}],"text":"There are several AL methods that you can use to open files, import and export files to and from Business Central, and more. Handling files in Business Central is done through the File data type, which provides methods to open, read, write, and close files. Learn more about the various methods in methods-auto/file/file-data-type.\nA couple of best practices for working with files are:\n Use fully qualified paths to eliminate ambiguity.\n Make sure to handle file exceptions and errors properly.\n Be aware of operating system file access restrictions when designing applications that use files. Consider which users have access to files and directories and what Access Control List (ACL) that you need to apply to file directories.\n## Text encoding\nText encoding is the process of transforming bytes of data into readable characters for users of a system or program. When you import a file as text or as a stream, the text encoding format ensures that all the language-specific characters are represented correctly in Business Central. When you export a file as text or as a stream, the text encoding format ensures that all the language-specific characters are represented correctly in the system or program that will read the exported file.\n## Encoding formats\nYou can specify text encoding for the following objects.\nObject or data type|Learn more in...\nXMLports|TextEncoding property \\(XMLports\\)<properties/devenv-textencoding-property>\nFile|methods-auto/file/file-open-method\nBLOB|methods-auto/blob/blob-createinstream-method<br /><br /> CreateOutstream method \\(BLOB\\)<methods-auto/library>\nThere are several industry text encoding formats and different systems support different formats. Internally, Business Central uses Unicode encoding. For exporting and importing data with an XMLport, it supports MS-DOS, UTF-8, UTF-16, and Windows encoding formats.\nData is imported and exported as follows:\n When data is imported from an external file, it's read using the format that's specified by the TextEncoding property or parameter, and then converted to Unicode in Business Central.\n When data is exported to an external file, it's converted from Unicode in Business Central, and then written to the file in the format that is specified by the TextEncoding property or parameter.\nYou should set the text encoding to the encoding format that's compatible with the system or program that you're exporting to or importing from. The following sections describe the available text encoding formats.\n### MS-DOS encoding format\nMS-DOS encoding, which is also referred to as OEM encoding, is an older format than UTF-8 and UTF-16, but it's still widely supported.\nMS-DOS encoding requires a different character set for each language. When the property is set to MS-DOS, text is encoded by using the system locale language of the computer that is running Business Central Server instance. So, if you use MS-DOS encoding, you should set the system locale language of server instance computer to match the language of the data that is being imported or exported. For example, if an XMLport includes text in Danish, then you should set the system locale language of the server instance computer to Danish before the XMLport is run.\nYou should choose MS-DOS with XMLports that were created in earlier versions of Business Central.\n### UTF-8 encoding format\nUTF-8 encoding is a Unicode Transformation Format that uses one byte \\(8 bits\\) to encode each character. UTF-8 is based on the Unicode character set, which includes most characters of all languages in a single character set.\nUnlike MS-DOS, when you use UTF-8, you don't have to consider the language settings of Business Central Server instance or the external system or program that will read or write the data.\nUTF-8 is compatible with ASCII so that it understands files written in ASCII format.\nUTF-8 is the most common encoding format and the recommended setting if you aren't sure of the format that's supported by the system that you're integrating with.\n### UTF-16 encoding format\nUTF-16 encoding resembles UTF-8 except that UTF-16 uses 2 bytes \\(16 bits\\) to encode each character. UTF-16 is also based on the Unicode character set, so you don't have to consider the language setting of Business Central Server instance or the external system or program that reads or writes the data.\nUTF-16 includes two encoding schemes, which mandate the byte order: UTF-16LE and UTF-16BE. The schemas are supported as follows:\n When exporting, the file is written using UTF-16LE encoding.\n When importing, the file is read using the UTF-16, UTF-16LE, or UTF-16BE, depending on encoding scheme of the file itself.\nA UTF-16 encoded file will typically be larger than the same file encoded with UTF-8, except for Eastern language character sets, which will typically be smaller.\nUTF-16 is incompatible with ASCII so that it won't understand files written in ASCII format.\n> NOTE\n> The methods-auto/text/text-data-type 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>.\n### Windows format\nWindows encoding is also referred to as ANSI encoding. If you set the text encoding to Windows, you can import and export text files that are based on the Windows codepage determined by the system locale on the Business Central Server. As a result, you don't have to consider the language setting of Business Central Server instance computer or the external system or program that reads or writes the data.\nFor example, if an XMLport can import bank files from a foreign bank in addition to a domestic bank, use Windows encoding instead of MS-DOS encoding to avoid changing the language of the Business Central Server instance computer.\n> NOTE\n> In Business Central online, you have no control over the system locale on Business Central Server. Here, it's recommended to use UTF8/UTF16 for text encodings instead.\n## Related information\nTextEncoding property (XMLports)<properties/devenv-textencoding-property>\nFile data type<methods-auto/library>"}