Cargo Features
rustcms-axum-xml has no features set by default.
[dependencies]
rustcms-axum-xml = { version = "0.3.0", features = ["encoding"] }
- encoding
-
Enables encoding of quick-xml ^0.26
quick-xml:
Enables support of non-UTF-8 encoded documents. Encoding will be inferred from the XML declaration if it is found, otherwise UTF-8 is assumed.
Currently, only ASCII-compatible encodings are supported. For example, UTF-16 will not work (therefore,
quick-xml
is not standard compliant).Thus, quick-xml supports all encodings of
encoding_rs
except these:You should stop processing a document when one of these encodings is detected, because generated events can be wrong and do not reflect a real document structure!
Because these are the only supported encodings that are not ASCII compatible, you can check for them:
use quick_xml::events::Event; use quick_xml::reader::Reader; let xml = to_utf16le_with_bom(r#"<?xml encoding='UTF-16'><element/>"#); let mut reader = Reader::from_reader(xml.as_ref()); reader.config_mut().trim_text(true); let mut buf = Vec::new(); let mut unsupported = false; loop { if !reader.decoder().encoding().is_ascii_compatible() { unsupported = true; break; } buf.clear(); match reader.read_event_into(&mut buf).unwrap() { Event::Eof => break, _ => {} } } assert_eq!(unsupported, true);
This restriction will be eliminated once issue #158 is resolved.
rustcms-axum-xml has 1 feature without comment.