web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Verified answer
    CU08071217-0 Profile Picture
    on at
    XMLPORT UTF-8
    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.
  • Gerardo Rentería García Profile Picture
    22,623 Most Valuable Professional on at
    XMLPORT UTF-8
    Hi
    Can you add the following property to the xmlport object?
     TextEncoding = UTF8;
    xmlport 90000 "TEST EXPORT UTF"
    {
        Format = Xml;
    BR
    GR

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,669 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,668

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,203

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans