Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix messy code bug of prompt_passward on Windows OS #98

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ libc = "0.2"
windows-sys = { version = "0.52", features = ["Win32_Foundation", "Win32_System_Console", "Win32_Storage_FileSystem", "Win32_Security", "Win32_System_SystemServices"] }

[dependencies]
rtoolbox = { path = "../rtoolbox", version = "0.0" }
rtoolbox = "0.0.2"
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ pub fn prompt_password_from_bufread(

/// Prompts on the TTY and then reads a password from TTY
pub fn prompt_password(prompt: impl ToString) -> std::io::Result<String> {
#[cfg(target_family = "windows")]
{
use windows_sys::Win32::System::Console::SetConsoleOutputCP;
unsafe {
SetConsoleOutputCP(65001); // 65001 is UTF-8
};
}
print_tty(prompt.to_string().as_str()).and_then(|_| read_password())
}

Expand Down