Skip to content

using .NET 8 leads to errors with umlauts #807

@wsigel

Description

@wsigel

When using the Save function like:

InvoiceDescriptor descriptor = InvoiceDescriptor.CreateInvoice(......);
descriptior.AddNote("Abrechnung für ...");
descriptor.Save("zugferd.xml", ...);      

the written xml will have a content with misspelled umlauts even though the encoding states "UTF-8".:

<ram:Content>Abrechnung für ...</ram:Content>

This happens when using .NET 8. The error does not happen when using the .NET framework (I've tried 4.7.2).

As a workaround for .NET 8 I found the following:

using (MemoryStream ms = new MemoryStream())
{
   
    descriptor.Save(ms, ZUGFeRDVersion.Version23, Profile.Comfort, ZUGFeRDFormats.CII);

    ms.Position = 0;
   
    string xmlContent;
    using (StreamReader reader = new StreamReader(ms, Encoding.UTF8))
    {
        xmlContent = reader.ReadToEnd();
    }
    
    var utf8WithBom = new UTF8Encoding(true); // BOM einschließen
    File.WriteAllText("zugferd-invoice.xml", xmlContent, utf8WithBom);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions