File tree Expand file tree Collapse file tree 4 files changed +20
-42
lines changed
kotlin-codepoints-deluxe/src/commonMain/kotlin
commonImplementation/kotlin Expand file tree Collapse file tree 4 files changed +20
-42
lines changed Original file line number Diff line number Diff line change 11package de.cketti.codepoints.deluxe
22
3+ import de.cketti.codepoints.CodePoints
34import de.cketti.codepoints.appendCodePoint as intAppendCodePoint
45
56/* *
6- * Appends the string representation of the [codePoint] argument to this sequence .
7+ * Appends the string representation of the [codePoint] argument to this Appendable and returns this instance .
78 *
8- * The argument is appended to the contents of this sequence.
9- * The length of this sequence increases by [CodePoint.charCount].
9+ * To append the codepoint, [Appendable.append(Char)][Appendable.append] is called [CodePoints.charCount] times.
1010 *
1111 * The overall effect is exactly as if the argument were converted to a char array by the function
12- * [CodePoint .toChars] and the characters in that array were then appended to this sequence .
12+ * [CodePoints .toChars] and the characters in that array were then appended to this Appendable .
1313 */
14- fun StringBuilder .appendCodePoint (codePoint : CodePoint ): StringBuilder = intAppendCodePoint(codePoint.value)
14+ fun < T : Appendable > T .appendCodePoint (codePoint : CodePoint ): T = intAppendCodePoint(codePoint.value)
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- @file:Suppress(
2- " EXTENSION_SHADOWED_BY_MEMBER" , // Kotlin/JVM aliases StringBuilder to j.l.StringBuilder.
3- " KotlinRedundantDiagnosticSuppress" , // Above suppression only needed for JVM.
4- )
5-
61package de.cketti.codepoints
72
3+ import de.cketti.codepoints.CodePoints.highSurrogate
4+ import de.cketti.codepoints.CodePoints.isBmpCodePoint
5+ import de.cketti.codepoints.CodePoints.lowSurrogate
6+
87/* *
9- * Appends the string representation of the [codePoint] argument to this sequence .
8+ * Appends the string representation of the [codePoint] argument to this Appendable and returns this instance .
109 *
11- * The argument is appended to the contents of this sequence.
12- * The length of this sequence increases by [CodePoints.charCount].
10+ * To append the codepoint, [Appendable.append(Char)][Appendable.append] is called [CodePoints.charCount] times.
1311 *
1412 * The overall effect is exactly as if the argument were converted to a char array by the function
15- * [CodePoints.toChars] and the characters in that array were then appended to this sequence .
13+ * [CodePoints.toChars] and the characters in that array were then appended to this Appendable .
1614 */
17- expect fun StringBuilder.appendCodePoint (codePoint : Int ): StringBuilder
15+ fun <T : Appendable > T.appendCodePoint (codePoint : Int ): T = apply {
16+ if (isBmpCodePoint(codePoint)) {
17+ append(codePoint.toChar())
18+ } else {
19+ append(highSurrogate(codePoint))
20+ append(lowSurrogate(codePoint))
21+ }
22+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments