Should size be extended to variables?

Mark Waddingham mark at livecode.com
Mon Sep 5 09:49:30 EDT 2016


On 2016-08-20 23:11, Richard Gaskin wrote:
> In all cases, the data is read and written in binary mode.
> 
> If neither "number of bytes of" or "number of chars" will help, how
> can I know the true byte length of a chunk of data?

The true byte length of a chunk of data is 'the number of bytes of' so 
I'm not entirely clear on what you are asking for.

If you are existing data from a file, and finding where it is then 
surely you know:

   1) its offset

   2) its length (in bytes)

If you didn't know either you wouldn't be able to load it and use it 
(after decoding it).

A value only gets a 'byte length' when it is actually encoded as binary 
data. For example, the length of a string encoded as UTF8 can be 
determined by using:

   the number of bytes in textEncode(tString, "utf8")

However, an encoding of a string on disk might include a prefix 
describing the size of the string, and might or might not include a 
trailing NUL byte.

Warmest Regards,

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list