|
Boost : |
From: Bobby Ward (bobbyrward_at_[hidden])
Date: 2006-07-18 14:46:22
I actually spent yesterday trying to figure out why my XML writing code was
all messed up.
<color red="
Took me a while to figure that one out.
On 7/18/06, Philipp Henkel <threadpool_at_[hidden]> wrote:
>
> Dear all,
>
> I wondered about boost::format's printf behaviour regarding char's.
> There seems to be no difference between the two format pattern "%c" and
> "%d". boost::format does not interpret chars as decimal values when using
> "%d".
>
> Please take a look a the following example:
>
> unsigned char foo = 65;
> printf("foo = %d", foo); // output is "foo = 65"
>
> std::string bar = (boost::format("foo = %d\n") % foo).str();
> printf(bar.c_str()); // output is "foo = A" which is what I want when
> using
> "%c"
>
> Is this behaviour intended? From my point of view it's dangerous because
> printf users
> do not expect it. Furthermore it may lead to string truncations because
> of
> string
> terminators (char is 0) which are inserted by accident.
>
> Did I overlook something?
>
> I'm using boost 1.33.1 / VC8.
>
> Best regards,
> Philipp
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
-- Bobby Ward ------------------------------ bobbyrward_at_[hidden] http://sf.net/projects/combustion
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk