mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #5827 from samueltardieu/issue-5826
printf: %c prints the first byte of its argument
This commit is contained in:
@@ -45,7 +45,7 @@ impl<'a, T: Iterator<Item = &'a FormatArgument>> ArgumentIter<'a> for T {
|
||||
};
|
||||
match next {
|
||||
FormatArgument::Char(c) => *c,
|
||||
FormatArgument::Unparsed(s) => s.chars().next().unwrap_or('\0'),
|
||||
FormatArgument::Unparsed(s) => s.bytes().next().map_or('\0', char::from),
|
||||
_ => '\0',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,3 +644,8 @@ fn partial_char() {
|
||||
"printf: warning: bc: character(s) following character constant have been ignored\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn char_as_byte() {
|
||||
new_ucmd!().args(&["%c", "🙃"]).succeeds().stdout_only("ð");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user