Skip to main content

Notifications

Announcements

No record found.

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  ?
  • Verified answer
    CU08071217-0 Profile Picture
    CU08071217-0 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.
  • gdrenteria Profile Picture
    gdrenteria 12,851 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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans