Output raw bytes in karma

Stephan Menzel <[email protected]> Fri, 26 Oct 2018 14:11:51 +0200
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <CAEQ568vCstGu=ScaC49pkoJ_Vcm28XjfHHMPHkLspXD0O29ijA@mail.gmail.com>
Hello all,

I would like to output a string containing binary data to a stream. To test
this, I generally use a string with a null byte somewhere in the middle.
With karma, all my efforts using the string generator only output till the
null byte. I have tried all of those:

const std::string binary_sample("Hello\0 World", 12);

// naive
os << karma::format(karma::string, binary_sample);

// many bytes
os << karma::format(*karma::byte_, binary_sample);

// explicity tell how many bytes
os << karma::format(karma::repeat(binary_sample.length())[karma::byte_],
binary_sample);

None yield the desired result. The stream only contains the string till
'Hello'. How can I achieve this? Any suggestions?

Cheers,
Stephan

_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general