Browse thread
sprintf-Bug?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Oliver Bandel <oliver@f...> |
| Subject: | Re: [Caml-list] sprintf-Bug? |
On Sun, Feb 04, 2007 at 02:11:43PM +1300, Jonathan Roewen wrote: > Don't think so. I'm pretty sure padding of strings is only with > spaces. The format-string "%02s" should make a '0' instead of ' ' as filling, IMHO. > Padding of numbers has to be specified for a number format. IMHO "%2s" should make a string of at least two chars length, fillingup with ' ' on the left side. And "%0s" should make it with a filling-char '0' instead of filling-chars ' '. > > let hex_of_byte b = Printf.sprintf "%02X" b;; > > Why you'd use two sprintfs is the real oddity =P The inner sprintf makes hex from int and the outer makes two-char-string instead of one-char-string. Or how to make hex-output with filling '0' instead of ' ' for two-char length strings? Would a "%00X" work?! Ciao, Oliver