Terminology concerning strings
Roland Illig
roland.illig at gmx.de
Wed Apr 6 17:00:34 UTC 2005
Roland Illig wrote:
> Roland Illig wrote:
>
>> Hi all,
>>
>> in the last time I have programmed a bit with strings, and I have
>> found four properties of them which need to be distinguished and which
>> should be named consistently throughout the whole Midnight Commander.
>>
>> * the _size_ of a string (as well as for other objects) is the number of
>> bytes that is allocated for it. For arrays, it is the number of
>> entries of the array. For strings it is at least _length_ + 1.
>
>
> To clarify this item: I want to continue using '\0'-terminated strings,
> and I also want to regard them as arrays. The second sentence above is a
> bit misleading, so here's a second try.
>
> * the _size_ of a string (which is regarded as an array of an arbitrary
> character type) is the number of array elements that may be accessed.
And here is the reason _why_ I want to continue using '\0'-terminated
strings in the next time. Most library functions expect their arguments
to be '\0'-terminated multibyte strings, so we have to provide them a
trailing '\0' anyway.
For internal processing, we could invent some new string datatypes that
have an explicit length field. But as long as we don't have such a
datatype, we should make work easy and stick to the old convention of
'\0'-terminating our strings. That way, we don't have to pass an extra
length argument around to every function that does string-processing.
All that might change in future, but it's not urgent.
Roland
More information about the mc-devel
mailing list