insertCodePointAt
Inserts the specified code point value into this StringBuilder at the specified index and returns this instance.
For basic (BMP) code points, inserts a single Char value. For supplementary code points, inserts two Char values representing the surrogate pair.
Since Kotlin
2.5Parameters
index
The position at which to insert the code point.
value
The code point to insert.
See also
Throws
if index is less than zero or greater than the length of this string builder.
Samples
import kotlin.text.unicode.*
import kotlin.test.*
fun main() {
//sampleStart
val builder = StringBuilder("ππ Kotlin")
// suppose we want to insert another supplementary code point after the first two
val position = builder.offsetByCodePoints(0, codePointOffset = 2)
println(position) // 4
builder.insert(position, CodePoint(0x1F60B))
println(builder.toString()) // πππ Kotlin
//sampleEnd
}Content copied to clipboard