File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -674,3 +674,38 @@ fn issue868() {
674674 ) ,
675675 }
676676}
677+
678+ /// Regression test for https://github.com/tafia/quick-xml/pull/888.
679+ #[ cfg( feature = "encoding" ) ]
680+ #[ test]
681+ fn issue888 ( ) {
682+ #[ derive( Debug , PartialEq , Deserialize ) ]
683+ struct Root {
684+ #[ serde( rename = "@list" ) ]
685+ list : Vec < String > ,
686+ }
687+
688+ let xml = r#"
689+ <?xml version="1.0" encoding="windows-1251"?>
690+ <root list="текст требующий декодирования"/>"# ;
691+
692+ let ( xml, enc, _) = dbg ! ( encoding_rs:: WINDOWS_1251 . encode( xml) ) ;
693+ assert_eq ! (
694+ enc,
695+ encoding_rs:: WINDOWS_1251 ,
696+ "windows-1251 should be used for the test"
697+ ) ;
698+
699+ let data: Root = quick_xml:: de:: from_reader ( xml. as_ref ( ) ) . unwrap ( ) ;
700+ assert_eq ! (
701+ data,
702+ Root {
703+ list: vec![
704+ // Translation from Russian:
705+ "текст" . to_string( ) , // text
706+ "требующий" . to_string( ) , // that-requires
707+ "декодирования" . to_string( ) , // decoding
708+ ] ,
709+ }
710+ ) ;
711+ }
You can’t perform that action at this time.
0 commit comments