KT-23356 Cross-platform function to convert CharArray slice to String

Signed-off-by: Valeriy Zhirnov <neonailol@gmail.com>
This commit is contained in:
Neonailol
2018-05-21 17:15:00 +03:00
committed by Ilya Gorbunov
parent 16ebcc6e77
commit ede2e227c2
4 changed files with 56 additions and 2 deletions
+18
View File
@@ -7,6 +7,24 @@ package kotlin.text
import kotlin.js.RegExp
/**
* Converts the characters in the specified array to a string.
*/
@SinceKotlin("1.2")
@kotlin.internal.InlineOnly
public actual inline fun String(chars: CharArray): String {
return js("String.fromCharCode").apply(null, chars)
}
/**
* Converts the characters from a portion of the specified array to a string.
*/
@SinceKotlin("1.2")
public actual fun String(chars: CharArray, offset: Int, length: Int): String {
return String(chars.copyOfRange(offset, offset + length))
}
@kotlin.internal.InlineOnly
public actual inline fun String.toUpperCase(): String = asDynamic().toUpperCase()