Re: Calculate length of byte string with embedded nulls



Angus wrote:

Hello

I have a stream of bytes - unsigned char*.

If it's a text stream,
then I suspect that you may be wanting to calculate
the length of the "line" rather than the length of a string.
Lines of text are terminated by a newline character ('\n').
The way to find the length of the line is to do it
while the line is being read.

But the 'string' may contain embedded nulls.
So not like a traditional c string terminated with a null.

I need to calculate the length of these arrays
but can't use strlen because
it just stops counting at the first null it finds. so how to do it?


--
pete
.



Relevant Pages

  • Re: "Read stuff from a file and chop it up to do stuff" code advice wanted.
    ... ;; This function returns TRUE if any character ... (if (char< char #\!) ... a stream and an array to hold characters in temp memory. ... ;; resulting string. ...
    (comp.lang.lisp)
  • Re: wofstream
    ... >I found that wide char file stream doesn't write national symbols. ... How can I switch text encoding? ... that includes a codecvt facet for the conversion. ...
    (microsoft.public.vc.stl)
  • Re: Sending Chr(255) to Serial Port
    ... The fact IS, that SerialPort IS A STREAM, it has a property called ... list that appears after you press the dot. ... Why didn't they keep char, ... Write does not accept a Stream, ...
    (microsoft.public.dotnet.general)
  • Re: XmlReader and first char
    ... A null char is a definite signal that the ... I am not sure why the white space in the ... My guess is that the stream has been created using a UTF-16 (or ...
    (microsoft.public.dotnet.framework)
  • Re: how to convert char* to File *
    ... implementation specific abstract data type which is by necessity ... associated with streams and is the only method to do I/O in standard C. ... The former is simply a pointer to type char. ... the only standard way is to open a FILE stream and to copy ...
    (comp.lang.c)