From 48aa5115c024d3973aad0f015e197f972ca70fb4 Mon Sep 17 00:00:00 2001 From: Cain <75994858+cainthebest@users.noreply.github.com> Date: Fri, 2 Feb 2024 21:10:41 +0000 Subject: [PATCH] fix: add xml utf8 and semver declaration --- crates/cli/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index ed19a3e..f20be84 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -279,7 +279,7 @@ fn output_result_json_pretty(result: T) -> Result<()> { #[cfg(feature = "xml")] fn output_result_xml(result: T) -> Result<()> { use quick_xml::{ - events::{BytesEnd, BytesStart, BytesText, Event}, + events::{BytesDecl, BytesEnd, BytesStart, BytesText, Event}, Writer, }; use serde_json::Value; @@ -292,6 +292,9 @@ fn output_result_xml(result: T) -> Result<()> { // Initialize the XML writer with a new, empty vector to store the XML data. let mut writer = Writer::new(Vec::new()); + // Write the XML 1.1 declaration + writer.write_event(Event::Decl(BytesDecl::new("1.1", Some("utf-8"), None)))?; + // Define a recursive function `json_to_xml` to convert the JSON value into XML // format. The function takes a mutable reference to the XML writer, an // optional key as a string slice, and a reference to the JSON value to be