[Tutor] More confusion on conversion

Alan Gauld alan.gauld at blueyonder.co.uk
Fri Oct 31 03:59:48 EST 2003


> Just for my own clarification, what string terminator is sent?  Not
> knowing exactly what port is, I assumed that when Vicki sent the 2
> characters, one after the other, that it would be equivalent to
sending
> a 2 byte string.

A string is a sequence of characters followed by a string terminator
- usually ASCII zero (aka the NULL character). This is true in most
modern languages. Pascal derivitives on the other hand usually store
strings as a count followed by the characters, so in C based languages
like Python

'0A' = '0'+'A'+'\0'

In Pascal based languages it would be:

'0A' = 2 + '0' + 'A'

So in either case sending the string '0A' actually sends
three bytes.

If you think about it it has to be so, since a string could
be arbitrarily long how else would the receiving end know where
the string ended?

Alan G.




More information about the Tutor mailing list