Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmldocument::save - use encoding as interpreted by get_write_encoding… #616

Closed
wants to merge 0 commits into from
Closed

Conversation

aral-matrix
Copy link

@aral-matrix aral-matrix commented Jun 19, 2024

… in xml_buffered_writer constructor

This patch fixes a minor bug in pugixml.cpp / xml_document::save:
The impl::xml_buffered_writer constructor invoked for buffered_writer uses get_write_encoding on parameter encoding, which can transform xml_encoding::encoding_auto into a specific encoding (e.g. encoding_utf8), stored in buffered_writer.encoding.

Accordingly, buffered_writer.encoding should be evaluated, while the pre-patch branch was still evaluating the unmodified function parameter encoding

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, the test_document.cpp checks would need to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant