Deprecate Char-to-Number conversions in stdlib (JVM and JS)
- Int.toChar was left non-deprecated because the replacement is not intrinsic yet. - Number.toChar was left non-deprecated because otherwise the deprecation propagates to the override, Int.toChar. KT-23451
This commit is contained in:
@@ -19,7 +19,7 @@ private object Category {
|
||||
val toBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
val fromBase64 = IntArray(128)
|
||||
for (i in toBase64.indices) {
|
||||
fromBase64[toBase64[i].toInt()] = i
|
||||
fromBase64[toBase64[i].code] = i
|
||||
}
|
||||
|
||||
// rangeStartDiff.length = 1482
|
||||
@@ -54,7 +54,7 @@ private fun categoryValueFrom(code: Int, ch: Int): Int {
|
||||
* Returns the Unicode general category of this character as an Int.
|
||||
*/
|
||||
internal fun Char.getCategoryValue(): Int {
|
||||
val ch = this.toInt()
|
||||
val ch = this.code
|
||||
|
||||
val index = binarySearchRange(Category.decodedRangeStart, ch)
|
||||
val start = Category.decodedRangeStart[index]
|
||||
@@ -70,7 +70,7 @@ internal fun decodeVarLenBase64(base64: String, fromBase64: IntArray, resultLeng
|
||||
var int = 0
|
||||
var shift = 0
|
||||
for (char in base64) {
|
||||
val sixBit = fromBase64[char.toInt()]
|
||||
val sixBit = fromBase64[char.code]
|
||||
int = int or ((sixBit and 0x1f) shl shift)
|
||||
if (sixBit < 0x20) {
|
||||
result[index++] = int
|
||||
|
||||
@@ -40,7 +40,7 @@ internal fun binarySearchRange(array: IntArray, needle: Int): Int {
|
||||
* Returns `true` if this character is a digit.
|
||||
*/
|
||||
internal fun Char.isDigitImpl(): Boolean {
|
||||
val ch = this.toInt()
|
||||
val ch = this.code
|
||||
val index = binarySearchRange(Digit.rangeStart, ch)
|
||||
val high = Digit.rangeStart[index] + 9
|
||||
return ch <= high
|
||||
|
||||
@@ -20,7 +20,7 @@ private object Letter {
|
||||
val toBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
val fromBase64 = IntArray(128)
|
||||
for (i in toBase64.indices) {
|
||||
fromBase64[toBase64[i].toInt()] = i
|
||||
fromBase64[toBase64[i].code] = i
|
||||
}
|
||||
|
||||
// rangeStartDiff.length = 356
|
||||
@@ -72,7 +72,7 @@ internal fun Char.isUpperCaseImpl(): Boolean {
|
||||
* - `0` otherwise.
|
||||
*/
|
||||
private fun Char.getLetterType(): Int {
|
||||
val ch = this.toInt()
|
||||
val ch = this.code
|
||||
val index = binarySearchRange(Letter.decodedRangeStart, ch)
|
||||
|
||||
val rangeStart = Letter.decodedRangeStart[index]
|
||||
|
||||
@@ -13,7 +13,7 @@ package kotlin.text
|
||||
// 4 ranges totally
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
internal fun Char.titlecaseCharImpl(): Char {
|
||||
val code = this.toInt()
|
||||
val code = this.code
|
||||
// Letters repeating <Lu, Lt, Ll> sequence and code of the Lt is a multiple of 3, e.g. <DŽ, Dž, dž>
|
||||
if (code in 0x01c4..0x01cc || code in 0x01f1..0x01f3) {
|
||||
return (3 * ((code + 1) / 3)).toChar()
|
||||
|
||||
@@ -15,7 +15,7 @@ package kotlin.text
|
||||
* Returns `true` if this character is a whitespace.
|
||||
*/
|
||||
internal fun Char.isWhitespaceImpl(): Boolean {
|
||||
val ch = this.toInt()
|
||||
val ch = this.code
|
||||
return ch in 0x0009..0x000d
|
||||
|| ch in 0x001c..0x0020
|
||||
|| ch == 0x00a0
|
||||
|
||||
Reference in New Issue
Block a user