Migrate deprecations in Native compiler
Replacing deprecated Char.toInt() with Char.code and Number.toChar() with Number.toInt().toChar(), where Number is not Int. KT-23451
This commit is contained in:
@@ -479,12 +479,12 @@ private class U32CString(val chars: CharArray): CValues<IntVar>() {
|
||||
var indexIn = 0
|
||||
var indexOut = 0
|
||||
while (indexIn < chars.size) {
|
||||
var value = chars[indexIn++].toInt()
|
||||
var value = chars[indexIn++].code
|
||||
if (value >= 0xd800 && value < 0xdc00) {
|
||||
// Surrogate pair.
|
||||
if (indexIn >= chars.size - 1) throw IllegalArgumentException()
|
||||
indexIn++
|
||||
val next = chars[indexIn].toInt()
|
||||
val next = chars[indexIn].code
|
||||
if (next < 0xdc00 || next >= 0xe000) throw IllegalArgumentException()
|
||||
value = 0x10000 + ((value and 0x3ff) shl 10) + (next and 0x3ff)
|
||||
}
|
||||
@@ -527,7 +527,7 @@ public fun CPointer<ShortVar>.toKStringFromUtf16(): String {
|
||||
val chars = CharArray(length)
|
||||
var index = 0
|
||||
while (index < length) {
|
||||
chars[index] = nativeBytes[index].toChar()
|
||||
chars[index] = nativeBytes[index].toInt().toChar()
|
||||
++index
|
||||
}
|
||||
return chars.concatToString()
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ fun String.quoteAsKotlinLiteral(): KotlinExpression = buildString {
|
||||
when (c) {
|
||||
in charactersAllowedInKotlinStringLiterals -> append(c)
|
||||
'$' -> append("\\$")
|
||||
else -> append("\\u" + "%04X".format(c.toInt()))
|
||||
else -> append("\\u" + "%04X".format(c.code))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user