> Date: Mon, 15 Oct 2001 23:44:55 -0400
> From: Peter Shenkin <[log in to unmask]>
On the contrary, you said there was no easy way to distinguish between the
two forms of string;
I claimed that it is easy, and presented two ways in which it could be
achieved.
As for the hashing library, storing trailing 00h characters instead of blanks
has some advantages over FFh characters.
If the length is stored, storing the length as a trailing
character is probably to be preferred over storing it at the beginning.
Of the two methods re the hashing library, the first is probably
the superior (no aditional characters stored), and the padding character
can be stripped off easily enough for printing etc
> 3. Inability to distinguish between a stored character string
> and the same string with trailing blanks. For instance,
> in writing a hashing/associative-array library, there was
> no simple way to distinguish between "foo" and "foo "
> in a stored string.
=========
# If the values "foo" and "foo " are stored in the _same_ string, they
# can be differentiated simply by padding "foo" on the right with "FF"H
# characters, or by "00"H characters, or whatever suits, and leaving "foo "
# as is. (The REPEAT or CHAR function can facilitate this.)
# Alternatively, the first character position can be reserved for the length
# (3 positions for the first and 5 for the second), with the actual character of the string
# being held in the 2nd thru 6th positions. The whole string (including the length
# character) can be treated by the hashing procedure as an ordinary string,
# and thus is sufficient to distinguish between the two values "foo" and "foo ".
# [And if one character position for the length is not enough, then two characters
# can be used.]
|