Chapter 4 Advanced Expressions: Evaluating Text 91
The difference between “abc” and “abd” is -1 (based on the third pair-wise
character comparison).
The difference between “@” and “abc” is -33.
The difference between “1” and “abc” is -47.
The following is the syntax for the COMPARE operation.
text.COMPARE("string")
Extracting the nth Integer from a String of Bytes that Represent Text
You can use the following operators to treat a string of bytes that represent text as
a sequence of 8-bit, 16-bit, or 32-bit signed or unsigned integers, and then extract
the nth integer from the sequence.
Converting Text to a Hash Value
You can convert a text string to a hash value by using the .HASH operator. This
operator returns a 31-bit positive integer as a result of the operation. Following is
the format of the expression:
text.HASH
This operator ignores case and white spaces. For example, after the operation, the
two strings "Ab c" and "a bc" would produce the same hash value.
Operations for Extracting the nth Integer from a String of Bytes that Represent Text
Operation Description
text.GET_SIGNED16(n,
endianness)Treats the string of bytes represented by text as a sequence of
16-bit signed integers and returns the nth integer. The second
argument takes a value of 0 for little endian or 1 for big
endian.
text.GET_SIGNED32(n,
endianness)Treats the string of bytes represented by text as a sequence of
32-bit signed integers and returns the nth integer. The second
argument takes a value of 0 for little endian or 1 for big
endian.
text.GET_SIGNED8(n)Treats the string of bytes represented by text as a sequence of
8-bit signed integers and returns the nth integer.
text.GET_
UNSIGNED16(n,
endianness)
Treats the string of bytes represented by text as a sequence of
16-bit unsigned integers and returns the nth integer. The
second argument takes a value of 0 for little endian or 1 for
big endian.
text.GET_
UNSIGNED8(n)Treats the string of bytes represented by text as a sequence of
8-bit unsigned integers and returns the nth integer.