microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
745 stars 244 forks source link

XmlDocument is saved with incorrect Encoding/Contents #6079

Closed daansaveyn closed 4 years ago

daansaveyn commented 4 years ago

Test.txt

Describe the bug Importing an XML File with UTF-8 encoding and saving it using the native XmlDocument type results in an incorrect XML File with UTF-8 BOM encoding.

To Reproduce Import/Export the attached XML file (please rename the extension) using the following code:

procedure TestEncodingIssue()
    var
        FileMgt: codeunit "File Management";
        TempBlobIn: codeunit "Temp Blob";
        TempBlobOut: codeunit "Temp Blob";
        InStr: InStream;
        OutStr: OutStream;
        XmlDoc: XmlDocument;
    begin
        FileMgt.BLOBImportFromServerFile(TempBlobIn, '\\por16-05-01\Temp\Test.xml');

        TempBlobIn.CreateInStream(InStr, TextEncoding::UTF8);

        XmlDocument.ReadFrom(InStr, XmlDoc);

        TempBlobOut.CreateOutStream(OutStr, TextEncoding::UTF8);
        XMLDoc.WriteTo(OutStr);

        FileMgt.BLOBExport(TempBlobOut, 'Test.xml', true);

    end;        

EDIT: the corrupt xml contents was caused by using the same Temp Blob variable. The encoding issue however remains.

Expected behavior The resulting XML File should be identical to the original File.

Screenshots Encoding original XML File (using Notepad++) (EDIT: ignore the corrupt body):

image

Resulting XML File (EDIT: ignore the corrupt body):

image

5. Versions:

atoader commented 4 years ago

Hi! Please take a minute to read the guidelines for this repository https://github.com/microsoft/AL and our collection of frequently asked questions https://github.com/Microsoft/AL/wiki/frequently-Asked-Questions .

As this repository is only for issues related to the AL compiler in latest developer preview environment for Dynamics 365 Business Central. We suggest that you open a support case or file a bug in Collaborate, to ensure that all Business Central users benefit from your catch as soon as possible.

To open a support case, you can:

If you file the bug in Collaborate, remember to include steps to reproduce the issue, and the Business Central build number and country version you're using.

daansaveyn commented 4 years ago

Hi! Please take a minute to read the guidelines for this repository https://github.com/microsoft/AL and our collection of frequently asked questions https://github.com/Microsoft/AL/wiki/frequently-Asked-Questions .

As this repository is only for issues related to the AL compiler in latest developer preview environment for Dynamics 365 Business Central. We suggest that you open a support case or file a bug in Collaborate, to ensure that all Business Central users benefit from your catch as soon as possible.

To open a support case, you can:

  • Open a support request to CSS through the PartnerSource portal
  • Contact your Service Account Manager (SAM) in your local subsidiary to understand what is included in your contract as of support incident and PAH (Partner Advisory Hours). Your SAM might also direct you "step by step" how to open a support request or how to get credentials, if this is the first time for you or your company

If you file the bug in Collaborate, remember to include steps to reproduce the issue, and the Business Central build number and country version you're using.

Hi,

Why isn't this a bug in the compiler? A similar issue was reported and solved here... https://github.com/Microsoft/AL/issues/630.

atoader commented 4 years ago

At the point when the issue was reported, this repository also handled issues related to the runtime. As stated in our readme, we have chosen to focus solely on developer experience issues.

fvet commented 4 years ago

Logged on collaborate

https://partner.microsoft.com/en-us/dashboard/collaborate/engagements/1173/feedback/wits/Bugs/358971