Fix case-insensitive character-wise comparison KT-45496

- Step 1: add failing tests
- Step 2: fix common case insensitive Char.equals
- Step 3: fix case insensitive String.equals in K/JS
- Step 4: enable unicode case folding in K/JS Regexes and
  string replacement (KT-45928)
- Step 5: fix case insensitive char comparison in K/N in String functions
  String.replace, equals, compareTo with ignoreCase
This commit is contained in:
Ilya Gorbunov
2021-04-05 11:46:39 +03:00
parent fc8b75be80
commit 22ca412dd2
6 changed files with 76 additions and 32 deletions
+4 -3
View File
@@ -230,9 +230,10 @@ public fun Char.equals(other: Char, ignoreCase: Boolean = false): Boolean {
if (this == other) return true
if (!ignoreCase) return false
if (this.uppercaseChar() == other.uppercaseChar()) return true
if (this.lowercaseChar() == other.lowercaseChar()) return true
return false
val thisUpper = this.uppercaseChar()
val otherUpper = other.uppercaseChar()
return thisUpper == otherUpper || thisUpper.lowercaseChar() == otherUpper.lowercaseChar()
}
/**