@@ -690,7 +690,7 @@ pub mod groups {
690
690
}
691
691
}
692
692
693
- // FIXME: #5516
693
+ // FIXME: #5516 should be graphemes not codepoints
694
694
// here we just need to indent the start of the description
695
695
let rowlen = str:: count_chars ( row, 0 , row. len ( ) ) ;
696
696
if rowlen < 24 {
@@ -708,14 +708,14 @@ pub mod groups {
708
708
desc_normalized_whitespace. push_char ( ' ' ) ;
709
709
}
710
710
711
- // FIXME: #5516
711
+ // FIXME: #5516 should be graphemes not codepoints
712
712
let mut desc_rows = ~[ ] ;
713
713
do each_split_within ( desc_normalized_whitespace, 54 ) |substr| {
714
714
desc_rows. push ( substr. to_owned ( ) ) ;
715
715
true
716
716
} ;
717
717
718
- // FIXME: #5516
718
+ // FIXME: #5516 should be graphemes not codepoints
719
719
// wrapped description
720
720
row. push_str ( desc_rows. connect ( desc_sep) ) ;
721
721
@@ -1581,4 +1581,31 @@ Options:
1581
1581
debug!(" generated: <<%s>>", usage);
1582
1582
assert!(usage == expected)
1583
1583
}
1584
+
1585
+ #[test]
1586
+ fn test_groups_usage_description_multibyte_handling() {
1587
+ let optgroups = ~[
1588
+ groups::optflag(" k", " k\u2013 w\u2013 ",
1589
+ "The word kiwi is normally spelled with two i's" ) ,
1590
+ groups:: optflag( "a" , "apple" ,
1591
+ "This \u201C description\u201D has some characters that could \
1592
+ confuse the line wrapping; an apple costs 0.51€ in some parts of Europe.") ,
1593
+ ] ;
1594
+
1595
+ let expected =
1596
+ ~"Usage : fruits
1597
+
1598
+ Options :
1599
+ -k --k–w– The word kiwi is normally spelled with two i' s
1600
+ -a --apple This “description” has some characters that could
1601
+ confuse the line wrapping; an apple costs 0.51 € in
1602
+ some parts of Europe .
1603
+ ";
1604
+
1605
+ let usage = groups::usage(" Usage : fruits", optgroups);
1606
+
1607
+ debug!(" expected: <<%s>>", expected);
1608
+ debug!(" generated: <<%s>>" , usage) ;
1609
+ assert ! ( usage == expected)
1610
+ }
1584
1611
}
0 commit comments