xmldocument::save - use encoding as interpreted by get_write_encoding… #616
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… in xml_buffered_writer constructor
This patch fixes a minor bug in
pugixml.cpp
/xml_document::save
:The
impl::xml_buffered_writer
constructor invoked forbuffered_writer
usesget_write_encoding
on parameterencoding
, which can transformxml_encoding::encoding_auto
into a specific encoding (e.g.encoding_utf8
), stored inbuffered_writer.encoding
.Accordingly,
buffered_writer.encoding
should be evaluated, while the pre-patch branch was still evaluating the unmodified function parameterencoding
Second component of the patch:
Explicitly specify UTF-8 encoding in the target file as at least some XML writers do this (e.g. LibreOffice).
Note: As I noticed post-submission, this patch fails a check vs. how an empty document should look like in
tests/test_document.cpp
- this is because the default encoding is UTF-8 and now specified in an empty file that is still fully valid. With the patch, thetest_document.cpp
checks would need to be updated.