compare_characters
Use the compare_characters function to compare two texts.
The function is capable of handling Unicode characters and word processor instructions.
compare_characters ( first; second )
The result of this function is of type NUMBER.
This function has two parameters:
- first, type TEXT. The first text to compare.
- second, type TEXT. The second text to compare.
All input is always converted to Unicode Normalization Form C (NFC). Tabs, paragraph breaks, and line breaks are handled as characters. Other word processor content, such as layout switches and graphical objects, is ignored in the comparison.
The comparison is case-sensitive. Characters are compared based on their Unicode character codes, which is for most locales not a correct lexicographical sort.
Paragraph breaks and line breaks are considered equal for comparison purposes.
The return value indicates how the parameters compare:
- 0 both first and second are identical
- < 0 first compares textually before second
- > 0 first compares textually after second
Examples
compare_characters ("abc" ; "abc")
Results in 0
compare_characters ("abc" ; "abcd")
Results in a value > 0
compare_characters ("Abc" ; "abc")
Results in a value < 0 ("A" < "a")
compare_characters ("10"; "9")
Results in a value > 0 ("1" < "9")
The compare_characters function is used to implement the text comparison operators (<, <=, =, <>, >=, >) when Enhanced Unicode Support is enabled.