0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-25 20:14:10 +08:00

use encoding interpreted by get_write_encoding in buffered_writer constructor

This commit is contained in:
aral-matrix 2024-07-07 11:19:52 +02:00
parent 2d42114ed1
commit 2039e448cf

View File

@ -7460,7 +7460,7 @@ namespace pugi
{
impl::xml_buffered_writer buffered_writer(writer, encoding);
if ((flags & format_write_bom) && encoding != encoding_latin1)
if ((flags & format_write_bom) && buffered_writer.encoding != encoding_latin1)
{
// BOM always represents the codepoint U+FEFF, so just write it in native encoding
#ifdef PUGIXML_WCHAR_MODE
@ -7474,7 +7474,7 @@ 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\""));
if (buffered_writer.encoding == encoding_latin1) buffered_writer.write_string(PUGIXML_TEXT(" encoding=\"ISO-8859-1\""));
buffered_writer.write('?', '>');
if (!(flags & format_raw)) buffered_writer.write('\n');
}