Re: Finding binary data (Was: Re: Comments on binary specification)

On 14/03/2013 09:26, Jirka Kosek wrote:
> On 13.3.2013 11:01, Michael Kay wrote:
>> 6.2 bin:unpack-string. This function is largely the composition of
>> binary-subsequence and decode-string, which makes it largely a
>> convenience function. The exception is that it can extract a subsequence
>> based on the presence of a terminator; which suggests the need for a
>> primitive such as bin:terminated-subsequence($in, $offset, $terminator),
>> or perhaps more primitive still bin:find($in, $offset, $search) which
>> returns the (relative?) offset of the first occurrence of $search after
>> the specified $offset.
> I like idea of bin:find(). Do you expect $search be just single octet or
> arbitrary long binary data?
I left that open for discussion deliberately. I see no reason not to 
generalize it to arbitrary length. For example, there are datasets in 
which searching for the next occurrence of x0D0A could be useful.

Michael Kay
Saxonica
>

Received on Thursday, 14 March 2013 09:55:50 UTC