Align JS String.equals/compareTo(ignoreCase) behavior with JVM #KT-48999

This commit is contained in:
Abduqodiri Qurbonzoda
2021-09-30 15:35:50 +00:00
committed by Space
parent b5f74ef9a6
commit f8bcba0b76
8 changed files with 77 additions and 30 deletions
@@ -44,6 +44,9 @@ internal actual inline fun String.nativeLastIndexOf(str: String, fromIndex: Int)
/**
* Returns `true` if this string is equal to [other], optionally ignoring character case.
*
* Two strings are considered to be equal if they have the same length and the same character at the same index.
* If [ignoreCase] is true, the result of `Char.uppercaseChar().lowercaseChar()` on each character is compared.
*
* @param ignoreCase `true` to ignore character case when comparing strings. By default `false`.
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
@@ -540,6 +543,8 @@ public inline fun String.codePointCount(beginIndex: Int, endIndex: Int): Int =
/**
* Compares two strings lexicographically, optionally ignoring case differences.
*
* If [ignoreCase] is true, the result of `Char.uppercaseChar().lowercaseChar()` on each character is compared.
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun String.compareTo(other: String, ignoreCase: Boolean = false): Int {