@@ -690,7 +690,7 @@ pub mod groups {
690690 }
691691 }
692692
693- // FIXME: #5516
693+ // FIXME: #5516 should be graphemes not codepoints
694694 // here we just need to indent the start of the description
695695 let rowlen = str:: count_chars ( row, 0 , row. len ( ) ) ;
696696 if rowlen < 24 {
@@ -708,14 +708,14 @@ pub mod groups {
708708 desc_normalized_whitespace. push_char ( ' ' ) ;
709709 }
710710
711- // FIXME: #5516
711+ // FIXME: #5516 should be graphemes not codepoints
712712 let mut desc_rows = ~[ ] ;
713713 do each_split_within ( desc_normalized_whitespace, 54 ) |substr| {
714714 desc_rows. push ( substr. to_owned ( ) ) ;
715715 true
716716 } ;
717717
718- // FIXME: #5516
718+ // FIXME: #5516 should be graphemes not codepoints
719719 // wrapped description
720720 row. push_str ( desc_rows. connect ( desc_sep) ) ;
721721
@@ -1581,4 +1581,31 @@ Options:
15811581 debug!(" generated: <<%s>>", usage);
15821582 assert!(usage == expected)
15831583 }
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+ }
15841611}
0 commit comments