Tokenize on Nulls?

I have a string with nulls as delimiters. Using the size, I can get it into a Juce string (it's a const char*). But I can't see how to tokenize it. I tried with '\0' as the delimiter character, but that crashes on a sig segv because the string is null (which maybe is a bug? Should a single char string with null be illegal?).

What other options? I'd rather use Juce tools than faff around in C.

 

Bruce

EDIT: maybe I didn't get my whole string... looks like, despite the size field, my string broke on nulls. So it would be best to go directly to a StringArray, if possible.

All the string functions work on null-terminated strings, so they won't scan past a null.. It's surely just a trivial loop to write it yourself though?

e.g.

while (*n != 0)
{
    strings.add (n);
    n += strlen (n) + 1;
}

I was just getting there. Even strtok and pals have trouble. It just feels odd to treat strings as chars in this century.

 

Thanks.