Skip to content

Commit

Permalink
try to fix windows
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre committed Jan 24, 2025
1 parent 2aa6434 commit 51d312e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/uu/printf/src/printf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,19 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let values: Vec<_> = match matches.get_many::<std::ffi::OsString>(options::ARGUMENT) {
Some(s) => s
.map(|os_str| {
let raw_bytes: Vec<u8> = os_str.clone().into_vec();
#[cfg(unix)]
{
let raw_bytes: Vec<u8> = os_str.clone().into_vec();
FormatArgument::Unparsed(
String::from_utf8(raw_bytes.clone())
.unwrap_or_else(|_| raw_bytes.iter().map(|&b| b as char).collect()),
)
}
#[cfg(windows)]
FormatArgument::Unparsed(String::from_utf8_lossy(&raw_bytes).into_owned())
{
let raw_bytes: Vec<u8> = os_str.clone().into();
FormatArgument::Unparsed(String::from_utf8_lossy(&raw_bytes).into_owned())
}
})
.collect(),
None => vec![],
Expand Down

0 comments on commit 51d312e

Please sign in to comment.