Boost logo

Boost :

From: Thore Karlsen (sid_at_[hidden])
Date: 2005-11-07 13:13:27


On Mon, 07 Nov 2005 21:47:43 +0800, "CN" <cnliou9_at_[hidden]> 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.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk