Skip to content

Commit

Permalink
xmldocument::save - use encoding as interpreted by get_write_encoding…
Browse files Browse the repository at this point in the history
… in xml_buffered_writer constructor
  • Loading branch information
aral-matrix committed Jun 19, 2024
1 parent ac0ef85 commit 41be193
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/pugixml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7466,7 +7466,15 @@ namespace pugi
if (!(flags & format_no_declaration) && !impl::has_declaration(_root))
{
buffered_writer.write_string(PUGIXML_TEXT("<?xml version=\"1.0\""));
if (encoding == encoding_latin1) buffered_writer.write_string(PUGIXML_TEXT(" encoding=\"ISO-8859-1\""));
switch( buffered_writer.encoding ) { // 2024-06-20 bugfix: use encoding as interpreted by get_write_encoding in xml_buffered_writer constructor
case encoding_latin1:
buffered_writer.write_string(PUGIXML_TEXT(" encoding=\"ISO-8859-1\""));
break;
case encoding_utf8:
buffered_writer.write_string(PUGIXML_TEXT(" encoding=\"UTF-8\"")); // 2024-06-03: explicit UTF-8 encoding
break;
default: break; // noop - other encodings are (currently) not supported / not explicitly stored in xml header
}
buffered_writer.write('?', '>');
if (!(flags & format_raw)) buffered_writer.write('\n');
}
Expand Down

0 comments on commit 41be193

Please sign in to comment.