Skip to content

Commit

Permalink
Fix encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
reiyw committed Mar 23, 2024
1 parent dc962b6 commit 923fef6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ssspam-bot/src/sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ impl Metadata {
.map(|s| {
let result = charset_normalizer_rs::from_bytes(&s.as_bytes().to_vec(), None);
if let Some(best) = result.get_best() {
if !matches!(
best.most_probably_language(),
charset_normalizer_rs::entity::Language::Japanese
| charset_normalizer_rs::entity::Language::English
) {
return s;
}
let decoder = Encoding::for_label(best.encoding().as_bytes()).unwrap();
decoder.decode(s.as_bytes()).0.into_owned()
} else {
Expand Down

0 comments on commit 923fef6

Please sign in to comment.