On Sat, Mar 17, 2001 at 02:02:55PM +0000, Alan Fry wrote:
> At 12:57:50 +0100, Sat, 17 Mar 2001 Bart Lateur wrote:
>
> >On Sat, 17 Mar 2001 11:17:10 +0000, Alan Fry wrote:
> > >So we really need to find a better way of isolating 'TEXT', 'styl'
> >>(and others like 'PICT' for example) from the string returned by
> >>LMGetScrapHandle. It must be set out somewhere in IM: the question is
> >>where.
> >
> >I'm too tired and too busy right now to go hunting for it, but I'm
> >pretty sure that somewhere in that data, there must be length fields,
> >that indicate how long the individual subsections are. Regexes shouldn't
> >even begin to come into play.
>
> No, you have misunderstood the nature of the problem.
I don't think Bart has misunderstood the problem at all.
Take the first four characters, which indicate the type. Take the next
however many bytes, which indicate the length of the section of that
type. Take the contents of the section, using the indicated length.
Repeat as necessary.
> In the clipboard the characters 'styl' precede a 'long' integer which
> contains the number of bytes to follow to make up the 'styl' record.
> 'TEXT' and 'PICT' records are treated similarly.
>
> The first two bytes of a 'styl' record comprise a 'short' which
> specifies the number of individual styles to be found in the record.
It seems to me that this is the only tricky part; some types use a long for
the length encoding, and some use a short. There must be a table of these
somewhere.
> So the problem devolves to one of isolating the sub-strings 'styl'
> and 'TEXT' (and possibly also 'PICT') plus their appropriate bytes
> from all the mush in which they are embedded in no consistent order.
>
> If Bart when he is not so tired and busy ;) can suggest a way of
> doing this without recourse to 'regexes' we would all be grateful.
Do you really think that the OS and existing applications uses regexes to
parse the contents of the clipboard?
Ronald