Skip to content

Commit

Permalink
Update helpers.rs (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
thttg committed Jan 23, 2024
1 parent 7e13064 commit accb07b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src-tauri/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,22 @@ pub fn decode_buffer(buf: Vec<u8>) -> (String, String) {
let actual_encoding = if chardet_encoding == "ascii" && charset_normalizer_encoding == "ascii" {
// Default to UTF-8 if both chardet and charset normalizer detect ASCII
Encoding::for_label("UTF_8".as_bytes()).unwrap_or(UTF_8)
} else if (chardetng_encoding == "gbk"
&& (chardet_encoding == "windows-1255" || charset_normalizer_encoding == "ibm866"))
} else if ((chardet_encoding == "koi8-r" && charset_normalizer_encoding == "koi8-r")
|| chardetng_encoding == "gbk"
&& (chardet_encoding == "windows-1255" || charset_normalizer_encoding == "ibm866"))
|| chardet_encoding == "x-mac-cyrillic"
|| charset_normalizer_encoding == "macintosh"
|| (chardet_encoding == "koi8-r" && charset_normalizer_encoding == "koi8-r")
|| (chardetng_encoding == "iso-8859-2" && chardet_encoding == "iso-8859-1")
{
// Use windows-1251 if both chardet and charset normalizer detect KOI8-R and for various other combinations
// Use windows-1251 for various combinations
Encoding::for_label("windows-1251".as_bytes()).unwrap_or(UTF_8)
} else if (chardetng_encoding == "windows-1252" && chardet_encoding == "windows-1251")
|| (chardet_encoding == "iso-8859-1"
&& (charset_normalizer_encoding == "iso-8859-2"
|| charset_normalizer_encoding == "windows-874"
|| charset_normalizer_encoding == "iso-8859-1"
|| charset_normalizer_encoding == "ibm866"))
|| (chardetng_encoding == "gbk" && chardet_encoding == "iso-8859-1")
|| charset_normalizer_encoding == "ibm866"
|| charset_normalizer_encoding == "euc-kr"))
|| (chardetng_encoding == "shift_jis" && chardet_encoding == "iso-8859-1")
{
// Use windows-1252 for various combinations
Expand Down

0 comments on commit accb07b

Please sign in to comment.