I'm trying to right-pad a string up to 9 characters, for example "12345" 
should become "12345    ", and the only idea I've come up with so far is to 
use clojure.core/format which states: "Formats a string using 
java.lang.String.format, see java.util.Formatter for format string syntax". 
However, 
there seems to be a discrepancy in what the Clojure format function returns 
compared with the Java formatter.

In Java, new Formatter().format("'%-9s'", "12345") correctly returns '12345 
   ' - the ' are there for legibility. String.format("'%-9s'", "12345")also 
returns the correctly padded string.

However, in Clojure (format "'%-9s'" "12345") returns '12345 ' - it has 
only padded the string by 1 space, and not 4 as with the Java version.

Also, (String/format "'%-9s'" (to-array "12345")) - taken from the 
clojure.core/format source and substituting parameters directly- returns '1 
       ', and (String/format "'%-9s'" (to-array '(\1 \2 \3 \4 \5))) returns '1 
'.

The one thing that works correctly is (String/format "'%-9s'" (to-array 
["12345"])) which returns '12345    '.

I'm not really clear on what's going wrong here, but clojure.core/format 
doesn't appear to be working as described - at least for a single string 
argument.

I'll continue to investigate, but if anyone can offer some comments to 
help? ...

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to