You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Original bug ID: 6942 Reporter: acascella Status: acknowledged (set by @damiendoligez on 2016-11-08T10:19:06Z) Resolution: open Priority: low Severity: feature Platform: x86_64 OS: GNU/Linux OS Version: 3.13.0-57-generi Version: 4.02.2 Category: standard library Monitored by:@gasche
I noticed that precision in formatters for strings is ignored. For instance Printf.printf "%.2" "Hello" will print "Hello".
In C, the equivalent call would print only the first two chars, "He". The precision is interpreted as the maximum number of bytes to be written to the output.
I know that the OCaml documentation for Printf doesn't specify the behavior of precision for strings, so this is not a bug. I was only wondering if there is a reason for not handling precision for strings, or if it will be a desirable feature to add.
Steps to reproduce
OCaml version 4.02.2
Printf.printf "%s" "Hello";;
Hello- : unit = ()
Printf.printf "%.2s" "Hello" ;;
Hello- : unit = ()
The text was updated successfully, but these errors were encountered:
Note that both "%10s" "%.10s" pad when the input string is less than 10 characters (and you can use "-" for padding to the right, but 0-padding is ignored). The part that was never implemented is cutting the input when the width specification is smaller than the string size.
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.