
8 Nov
2005
8 Nov
'05
2:38 p.m.
Hi! Thore,
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.
The usage of split() is indeed neat and handy to myself. Thank you very much! CN -- http://www.fastmail.fm - Access your email from home and the web