This commit is contained in:
Dmitry Belyaev 2022-09-24 01:41:02 +03:00
parent c95c1fb785
commit 802dab3b1b
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -120,21 +120,21 @@ async fn transcoder_task(
encoding_to: EncodingRef,
) {
let is_encodings_same = encoding_from.name() == encoding_to.name();
let is_src_encodig_native = UTF_8.name() == encoding_from.name();
let is_dst_encodig_native = UTF_8.name() == encoding_to.name();
let is_src_encoding_native = UTF_8.name() == encoding_from.name();
let is_dst_encoding_native = UTF_8.name() == encoding_to.name();
while let Some(FileData { name, data }) = rx.recv().await {
let new_data = if is_encodings_same {
data
} else {
task::block_in_place(move || {
let text = if is_src_encodig_native {
let text = if is_src_encoding_native {
String::from_utf8(data).unwrap()
} else {
encoding_from.decode(&data, DecoderTrap::Ignore).unwrap()
};
if is_dst_encodig_native {
if is_dst_encoding_native {
text.into_bytes()
} else {
encoding_to