web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

XMLPORT UTF-8

(1) ShareShare
ReportReport
Posted on by 4
Hello all, 
I am having a problem exporting an XMLPort from the format 'Xml' to UTF-8 format.  I have already tested this in many ways and each time I get UTF-16 format.

Test 1
 
xmlport 90000 "TEST EXPORT UTF"
{
    Format = Xml;
    Caption = 'TEST EXPORT UTF';
    Direction = Export;
    UseRequestPage = false;

    schema
    {
        textelement(RootNodeName)
        {
            tableelement(Item; Item)
            {
                fieldelement(No; Item."No.")
    ....
}  
pageextension 90016 "test export" extends "Item List"
{
    actions
    {
        addafter(History)
        {
            action(ExportItems)
            {
                Caption = 'Export Items';
                Promoted = true;
                PromotedCategory = Process;
                Image = Export;
                ApplicationArea = All;

                trigger OnAction()
                begin
                    testxml.TextEncoding(TextEncoding::UTF8);
                    testxml.Run();
                end;
            }
        }
    }


    var
        testxml: XmlPort 90000;
}
I also tried it with outstream but without success
 

Can anybody suggest a solution so the final XML has UTF-8 format  ?
I have the same question (0)
  • Gerardo Rentería García Profile Picture
    25,547 Most Valuable Professional on at
    Hi
    Can you add the following property to the xmlport object?
     TextEncoding = UTF8;
    xmlport 90000 "TEST EXPORT UTF"
    {
        Format = Xml;
    BR
    GR
  • Verified answer
    CU08071217-0 Profile Picture
    on at
    To export an XMLPort in UTF-8 format in Microsoft Dynamics 365 Business Central, you can follow these steps:
    1. Set the TextEncoding property of the XMLPort to UTF8:
     
     
    TextEncoding = UTF8;
    1. Optionally, you can also set the TextEncoding in AL code at runtime if needed:
     
     
    currXMLport.TextEncoding(TextEncoding::UTF8);
    1. Make sure the Format property of the XMLPort is set to either Fixed Text or Variable Text.
    2. When exporting data using the XMLPort, it will be converted from Unicode to UTF-8 encoding before being written to the file.
    3. UTF-8 is a Unicode Transformation Format that uses one byte (8 bits) to encode each character. It is based on the Unicode character set, which includes most characters of all languages in a single character set.
    4. UTF-8 is compatible with ASCII and is the most common encoding format recommended if you aren't sure of the format supported by the system you are integrating with.
    So in summary, set the TextEncoding property of the XMLPort to UTF8, optionally set it in code if needed, ensure the Format is Fixed or Variable Text, and the data will be exported in UTF-8 encoding. UTF-8 is a widely supported format that is compatible with ASCII.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,986 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,071 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 975 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans