
7 Nov
2005
7 Nov
'05
6:13 p.m.
On Mon, 07 Nov 2005 21:47:43 +0800, "CN" <cnliou9@fastmail.fm> wrote:
Hi!
I need to get non-null tokens from std::basic_string deliminated by null characters. For example, hopefully the following code
string str=string("X;Y\0\0Z\0",7); typedef tokenizer<boost::escaped_list_separator<char> > Tok; escaped_list_separator<char> sep(string(),string("\0;",2),string()); Tok tokens(str, sep); for(Tok::iterator i = tokens.begin();i != tokens.end();++i) cout << "<" << *i << ">";
will yield
<X><Y><Z>
instead of
<X><Y><><Z><> .
How about using the string_algo library instead? It handles NUL characters just fine. -- Be seeing you.