question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow specifying encodings other than UTF-8 in XML declaration written

See original GitHub issue

The UTF-8 encoding is hard coded in the ToXmlGenerator source code:

if (Feature.WRITE_XML_1_1.enabledIn(_formatFeatures)) {
    _xmlWriter.writeStartDocument("UTF-8", "1.1");
} else if (Feature.WRITE_XML_DECLARATION.enabledIn(_formatFeatures)) {
    _xmlWriter.writeStartDocument("UTF-8", "1.0");
} else {
    return;
}

Once ToXmlGenerator is final, there might not be an easy way to have other encodings such as ISO-8859-1:

<?xml version="1.0" encoding="ISO-8859-1"?>

See this question in Stack Overflow for reference.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:12
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cowtowncodercommented, May 14, 2020

I am only involved whenever Spring folks file bugs, but do not know their code base (and they don’t use, I think, Jackson JAX-RS provider). Their involvement would be needed even if new functionality / endpoints were added, for what that is worth.

1reaction
cowtowncodercommented, Dec 16, 2018

Ah. Yes, I see. So although underlying writer may actually use different encoding, xml declaration claims it is UTF-8. That’s not good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Declaring character encodings in HTML - W3C
Always declare the encoding of your document using a meta element with a charset attribute, or using the http-equiv and content attributes ( ......
Read more >
How default is the default encoding (UTF-8) in the XML ...
The Short Answer. Under the very specific circumstances of a UTF-8 encoded document with no external encoding information (which I understand from the ......
Read more >
Is “UTF-8” case-sensitive in XML declaration? - Coding Out Loud
At the beginning of an XML document, the XML declaration can optionally declare the document's encoding format.
Read more >
The XML Declaration (XML in a Nutshell, 2nd Edition)
The encoding attribute is optional in an XML declaration. If it is omitted and no metadata is available, then the Unicode character set...
Read more >
Character Encoding and MSXML | Microsoft Learn
For reliable processing, XML documents that use character encodings other than UTF-8 or UTF-16 must include an encoding declaration in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found