mirror of
https://github.com/mbilker/kbinxml-rs.git
synced 2026-09-07 01:55:13 -05:00
text_reader: support quick-xml without encoding_rs dependency
This commit is contained in:
@@ -68,6 +68,12 @@ impl EncodingType {
|
||||
Ok(val)
|
||||
}
|
||||
|
||||
pub fn from_label(label: &[u8]) -> Result<Self, KbinError> {
|
||||
Encoding::for_label(label)
|
||||
.ok_or(KbinErrorKind::UnknownEncoding.into())
|
||||
.and_then(Self::from_encoding)
|
||||
}
|
||||
|
||||
pub fn to_byte(&self) -> u8 {
|
||||
match *self {
|
||||
EncodingType::None => 0x00, // 0x00 >> 5 = 0
|
||||
|
||||
@@ -216,8 +216,10 @@ impl<'a> TextXmlReader<'a> {
|
||||
parent_collection.children_mut().push_back(collection);
|
||||
}
|
||||
},
|
||||
Ok(Event::Decl(_)) => {
|
||||
self.encoding = EncodingType::from_encoding(self.xml_reader.encoding())?;
|
||||
Ok(Event::Decl(e)) => {
|
||||
if let Some(encoding) = e.encoding() {
|
||||
self.encoding = EncodingType::from_label(&encoding?)?;
|
||||
}
|
||||
},
|
||||
Ok(Event::Eof) => break,
|
||||
Ok(_) => {},
|
||||
|
||||
Reference in New Issue
Block a user