Equivalize isLowerCase and isUpperCase behavior in all platforms #KT-46184
This commit is contained in:
@@ -51,17 +51,17 @@ internal fun Char.isLetterImpl(): Boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if this character is a lower case letter.
|
||||
* Returns `true` if this character is a lower case letter, or it has contributory property Other_Lowercase.
|
||||
*/
|
||||
internal fun Char.isLowerCaseImpl(): Boolean {
|
||||
return getLetterType() == 1
|
||||
return getLetterType() == 1 || code.isOtherLowercase()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if this character is an upper case letter.
|
||||
* Returns `true` if this character is an upper case letter, or it has contributory property Other_Uppercase.
|
||||
*/
|
||||
internal fun Char.isUpperCaseImpl(): Boolean {
|
||||
return getLetterType() == 2
|
||||
return getLetterType() == 2 || code.isOtherUppercase()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin.text
|
||||
|
||||
//
|
||||
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateUnicodeData.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
private object OtherLowercase {
|
||||
internal val otherLowerStart = intArrayOf(
|
||||
0x00aa, 0x00ba, 0x02b0, 0x02c0, 0x02e0, 0x0345, 0x037a, 0x1d2c, 0x1d78, 0x1d9b, 0x2071, 0x207f, 0x2090, 0x2170, 0x24d0, 0x2c7c, 0xa69c, 0xa770, 0xa7f8, 0xab5c,
|
||||
)
|
||||
internal val otherLowerLength = intArrayOf(
|
||||
1, 1, 9, 2, 5, 1, 1, 63, 1, 37, 1, 1, 13, 16, 26, 2, 2, 1, 2, 4,
|
||||
)
|
||||
}
|
||||
|
||||
internal fun Int.isOtherLowercase(): Boolean {
|
||||
val index = binarySearchRange(OtherLowercase.otherLowerStart, this)
|
||||
return index >= 0 && this < OtherLowercase.otherLowerStart[index] + OtherLowercase.otherLowerLength[index]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin.text
|
||||
|
||||
//
|
||||
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateUnicodeData.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
internal fun Int.isOtherUppercase(): Boolean {
|
||||
return this in 0x2160..0x216f
|
||||
|| this in 0x24b6..0x24cf
|
||||
}
|
||||
Reference in New Issue
Block a user