From d0cdeb87b71bd75f44d90ebb39e0e2a0ba561dda Mon Sep 17 00:00:00 2001 From: iAmir Date: Wed, 15 Nov 2023 14:05:30 +0330 Subject: [PATCH] handle charset_normalizer_rs results properly --- src-tauri/src/helpers.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/helpers.rs b/src-tauri/src/helpers.rs index e8c50dd8..b27abf50 100644 --- a/src-tauri/src/helpers.rs +++ b/src-tauri/src/helpers.rs @@ -13,11 +13,10 @@ pub fn decode_buffer(buf: Vec) -> (String, String, String) { first_encoding = charset2encoding(&detect(&buf).0).to_string(); // charset_normalizer_rs - second_encoding = from_bytes(&buf, None) - .get_best() - .unwrap() - .encoding() - .to_string(); + second_encoding = match from_bytes(&buf, None).get_best() { + Some(cd) => cd.encoding().to_string(), + None => "not_found".to_string(), + }; str_encoding = first_encoding.clone();