Compare two JS strings.
intN JS_CompareStrings(JSString *str1, JSString *str2);
| Name | Type | Description |
|---|---|---|
str1 |
JSString * |
First string to compare. |
str2 |
JSString * |
Second string to compare. |
JS_CompareStrings compares two JS strings, str1 and str2. If the strings are identical in content and length, JS_CompareStrings returns 0. If str1 is less than str2, the return value is less than 0. If str1 is greater than str2, the return value is greater than 0.
This function imposes a total order on all JavaScript strings, the same order imposed by the JavaScript string comparison operators (<, <=, >, >=), as described in ECMA 262-3 § 11.8.5. As the standard says:
The comparison of strings uses a simple lexicographic ordering on sequences of code point value values. There is no attempt to use the more complex, semantically oriented definitions of character or string equality and collating order defined in the Unicode specification. Therefore strings that are canonically equal according to the Unicode standard could test as unequal.
Page last modified 19:56, 5 Sep 2008 by Jorend