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:
@@ -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()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user