Allow specifying encodings other than UTF-8 in XML declaration written
See original GitHub issueThe 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:
- Created 5 years ago
- Reactions:12
- Comments:10 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Ah. Yes, I see. So although underlying writer may actually use different encoding, xml declaration claims it is UTF-8. That’s not good.