Skip to content

Commit

Permalink
fix cyrillic encodings
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Nov 11, 2023
1 parent aacf4b2 commit 274668b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
32 changes: 16 additions & 16 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src-tauri/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ use encoding::DecoderTrap;

pub fn decode_buffer(buf: Vec<u8>) -> String {
let result = detect(&buf);
let coder = encoding_from_whatwg_label(charset2encoding(&result.0));
let mut str_encoding = charset2encoding(&result.0);
// let's just say it's cp1251 if encoding is not detected
// FIXME: find a way to actually detect cp1251 and cp1252 from together
if str_encoding.len() < 1 {
str_encoding = "cp1251";
}

let coder = encoding_from_whatwg_label(str_encoding);
if coder.is_some() {
coder
.unwrap()
Expand Down

0 comments on commit 274668b

Please sign in to comment.