From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 66459BC0A for ; Sun, 4 Feb 2007 02:51:31 +0100 (CET) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l141pUZk021386 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 4 Feb 2007 02:51:31 +0100 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from first (dslb-088-073-125-126.pools.arcor-ip.net [88.73.125.126]) (authenticated bits=0) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id l141pUnE018186 for ; Sun, 4 Feb 2007 02:51:30 +0100 Received: by first (Postfix, from userid 501) id C1BAB36A7CF; Sun, 4 Feb 2007 02:51:23 +0100 (CET) Date: Sun, 4 Feb 2007 02:51:23 +0100 From: Oliver Bandel To: caml-list@inria.fr Subject: Re: [Caml-list] sprintf-Bug? Message-ID: <20070204015122.GA3882@first.in-berlin.de> References: <20070204010040.GC3829@first.in-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at discorde with ID 45C53C22.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bandel:01 in-berlin:01 byte:01 printf:01 sprintf:01 sprintf:01 wrote:01 imho:01 imho:01 oliver:01 oliver:01 caml-list:01 int:01 strings:01 strings:01 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