Skip to content

Commit

Permalink
handle charset_normalizer_rs results properly
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Nov 15, 2023
1 parent c165c9a commit d0cdeb8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src-tauri/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ pub fn decode_buffer(buf: Vec<u8>) -> (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();

Expand Down

0 comments on commit d0cdeb8

Please sign in to comment.