incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Pevtsov" <Ant...@moscow.vdiweb.com>
Subject RE: %{#*S} inserts NULs (was: Re: test for 21.strings.capacity)
Date Tue, 07 Mar 2006 16:56:10 GMT
Yes, here it is:

#include <string>
#include <rw_printf.h>

int main (int argc, char** argv)
{
    wchar_t* tmp = L"abc";
    std::basic_string<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> > s (tmp, 3);
    rw_printf ("%{#*S}\n", sizeof (wchar_t), &s);

    return 0;
}

I got "a\0b". Maybe, I use the %{#*S} in wrong way?


Thanks,
Anton Pevtsov.


-----Original Message-----
From: Martin Sebor [mailto:sebor@roguewave.com] 
Sent: Tuesday, March 07, 2006 19:48
To: stdcxx-dev@incubator.apache.org
Subject: %{#*S} inserts NULs (was: Re: test for 21.strings.capacity)


Anton Pevtsov wrote:
[...]
>> <>>Yes. That's the expected result. In general, the extended
>> formatting>directives (such as %{#*S}) format their arguments so that
>> they are human readable even when the arguments contain non-printable
>> characters.
> 
> 
> Here I meant the following. Suppose my
> basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > 
> contains the string "abc". And when I printed it out in the --trace 
> mode using the %{#*S} directive I have got "a\0b", but "abc" (or 
> "a\0b\0c\0" if each byte is printed) was expected. Is this correct?

No, that would not be correct. If there are no NULs in the string the
directive certainly shouldn't print any. Can you put together a small
test case? (The little program I copied in my previous response behaved
correctly.)

Martin

Mime
View raw message