Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/fix-stdout-readline-encoding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"shell": patch
"shell-js": patch
---

Fix incorrect stdout encoding when readline.
8 changes: 7 additions & 1 deletion plugins/shell/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const NEWLINE_BYTE: u8 = b'\n';
use tauri::async_runtime::{block_on as block_on_task, channel, Receiver, Sender};

pub use encoding_rs::Encoding;
#[cfg(not(windows))]
use encoding_rs::UTF_8 as SYSTEM_ENCODING;
#[cfg(windows)]
use encoding_rs::WINDOWS_1252 as SYSTEM_ENCODING;
use os_pipe::{pipe, PipeReader, PipeWriter};
use serde::Serialize;
use shared_child::SharedChild;
Expand Down Expand Up @@ -435,8 +439,10 @@ fn read_line<F: Fn(Vec<u8>) -> CommandEvent + Send + Copy + 'static>(
if n == 0 {
break;
}
let (cow, _, _) = SYSTEM_ENCODING.decode(&buf);
let decode_bytes = cow.into_owned().into_bytes();
let tx_ = tx.clone();
let _ = block_on_task(async move { tx_.send(wrapper(buf)).await });
let _ = block_on_task(async move { tx_.send(wrapper(decode_bytes)).await });
}
Err(e) => {
let tx_ = tx.clone();
Expand Down
Loading