mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
numfmt: treat multibyte chars as a single character (#11992)
* treat multibyte chars as a single character * add test for issue 11937
This commit is contained in:
@@ -620,7 +620,7 @@ fn transform_to(
|
||||
/// Right-aligns when `right_align` is true, left-aligns otherwise.
|
||||
/// Unlike `format!("{:>width$}")`, this handles widths larger than 65535.
|
||||
fn pad_string(s: &str, width: usize, fill: char, right_align: bool) -> String {
|
||||
let len = s.len();
|
||||
let len = s.chars().count();
|
||||
if len >= width {
|
||||
return s.to_string();
|
||||
}
|
||||
|
||||
@@ -1549,3 +1549,13 @@ fn test_si_format_precision_no_cap() {
|
||||
.succeeds()
|
||||
.stdout_is("1.23457M\n");
|
||||
}
|
||||
|
||||
// https://github.com/uutils/coreutils/issues/11937
|
||||
// numfmt: --format width accounting diverges from GNU for multi-byte --suffix
|
||||
#[test]
|
||||
fn test_multibyte_suffix_issue11937() {
|
||||
new_ucmd!()
|
||||
.args(&["--suffix=€", "--format=%10.2f", "692"])
|
||||
.succeeds()
|
||||
.stdout_is(" 692.00€\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user