Skip to content

Commit c4d1735

Browse files
authored
Merge pull request #22 from cketti/appendable
Change `StringBuilderExtensions` to `AppendableExtensions`
2 parents 8fa6142 + 52a94c3 commit c4d1735

File tree

8 files changed

+38
-60
lines changed

8 files changed

+38
-60
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package de.cketti.codepoints.deluxe
2+
3+
import de.cketti.codepoints.CodePoints
4+
import de.cketti.codepoints.appendCodePoint as intAppendCodePoint
5+
6+
/**
7+
* Appends the string representation of the [codePoint] argument to this Appendable and returns this instance.
8+
*
9+
* To append the codepoint, [Appendable.append(Char)][Appendable.append] is called [CodePoints.charCount] times.
10+
*
11+
* The overall effect is exactly as if the argument were converted to a char array by the function
12+
* [CodePoints.toChars] and the characters in that array were then appended to this Appendable.
13+
*/
14+
fun <T : Appendable> T.appendCodePoint(codePoint: CodePoint): T = intAppendCodePoint(codePoint.value)

kotlin-codepoints-deluxe/src/commonMain/kotlin/StringBuilderExtensions.kt

Lines changed: 0 additions & 14 deletions
This file was deleted.

kotlin-codepoints-deluxe/src/commonTest/kotlin/StringBuilderExtensionsTest.kt renamed to kotlin-codepoints-deluxe/src/commonTest/kotlin/AppendableExtensionsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package de.cketti.codepoints.deluxe
33
import kotlin.test.assertEquals
44
import kotlin.test.Test
55

6-
class StringBuilderExtensionsTest {
6+
class AppendableExtensionsTest {
77
@Test
88
fun appendCodePoint() {
99
val actual = buildString {

kotlin-codepoints/src/commonImplementation/kotlin/StringBuilderExtensions.kt

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package de.cketti.codepoints
2+
3+
import de.cketti.codepoints.CodePoints.highSurrogate
4+
import de.cketti.codepoints.CodePoints.isBmpCodePoint
5+
import de.cketti.codepoints.CodePoints.lowSurrogate
6+
7+
/**
8+
* Appends the string representation of the [codePoint] argument to this Appendable and returns this instance.
9+
*
10+
* To append the codepoint, [Appendable.append(Char)][Appendable.append] is called [CodePoints.charCount] times.
11+
*
12+
* The overall effect is exactly as if the argument were converted to a char array by the function
13+
* [CodePoints.toChars] and the characters in that array were then appended to this Appendable.
14+
*/
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+
}

kotlin-codepoints/src/commonMain/kotlin/StringBuilderExtensions.kt

Lines changed: 0 additions & 17 deletions
This file was deleted.

kotlin-codepoints/src/commonTest/kotlin/StringBuilderExtensionsTest.kt renamed to kotlin-codepoints/src/commonTest/kotlin/AppendableExtensionsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package de.cketti.codepoints
33
import kotlin.test.assertEquals
44
import kotlin.test.Test
55

6-
class StringBuilderExtensionsTest {
6+
class AppendableExtensionsTest {
77
@Test
88
fun appendCodePoint() {
99
val actual = buildString {

kotlin-codepoints/src/jvmMain/kotlin/StringBuilderExtensions.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)