In c, there's this very nice function strncmp(s1,s2,count) which compares two c strings, using at most count characters. count can be less than, more than, or equal to either or both of the lengths of the two strings. It can be used to see if two c-strings have the same prefix of some length.

Now, strncmp indeed seems to be packaged up in core.stdc.string, but i would like to use some something like it on 2 d strings (which, as i understand it, need not be zero-terminated).

I suppose it would be possible to do some conversion with toStringz() or something and then invoke the strncmp(), but that seems very wordy and also it's not clear that it would handle all pairs of d strings (e.g., what if there were some 0's in the first count characters?).

So i would like to call a d function which works on d strings, but don't want to write my own if one already exists. (At the very least, i'd have to get a much sharper understanding of d strings, whether internal 0's can occur, etc. And i would not want to do egregious string allocation.)

TIA for any info!


Reply via email to