From fd55c8795893ad7234d7c734086d6386450138f4 Mon Sep 17 00:00:00 2001 From: Daniel Alley Date: Sat, 27 Aug 2022 12:56:44 -0400 Subject: [PATCH] Assume UTF-8 for regex matches This code wouldn't have worked on any other encoding anyway --- examples/custom_entities.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/custom_entities.rs b/examples/custom_entities.rs index 49193f14..bb37ee48 100644 --- a/examples/custom_entities.rs +++ b/examples/custom_entities.rs @@ -35,8 +35,8 @@ fn main() -> Result<(), Box> { Ok(Event::DocType(ref e)) => { for cap in entity_re.captures_iter(e.as_bytes()) { custom_entities.insert( - reader.decoder().decode(&cap[1])?.into_owned(), - reader.decoder().decode(&cap[2])?.into_owned(), + String::from_utf8(cap[1].to_owned())?, + String::from_utf8(cap[2].to_owned())?, ); } }