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 c4ab28b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/uu/printf/src/printf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,24 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let format = format.as_bytes();

#[cfg(windows)]
let format = as_os_str().as_bytes_lossy();
let format = format.as_os_str().as_bytes_lossy();

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.as_os_str().as_bytes().to_vec();
FormatArgument::Unparsed(String::from_utf8_lossy(&raw_bytes).into_owned())
}
})
.collect(),
None => vec![],
Expand Down

0 comments on commit c4ab28b

Please sign in to comment.