11package de.cketti.codepoints
22
3- import de.cketti.codepoints.CommonCodePoints.isHighSurrogate
4- import de.cketti.codepoints.CommonCodePoints.isLowSurrogate
53import de.cketti.codepoints.CommonCodePoints.toCodePoint
64
75object CommonStringFunctions {
86 fun codePointAt (text : String , index : Int ): Int {
97 if (index !in text.indices) throw IndexOutOfBoundsException ()
108
119 val firstChar = text[index]
12- if (isHighSurrogate(firstChar ) && index + 1 < text.length) {
10+ if (firstChar. isHighSurrogate() && index + 1 < text.length) {
1311 val nextChar = text[index + 1 ]
14- if (isLowSurrogate(nextChar )) {
12+ if (nextChar. isLowSurrogate()) {
1513 return toCodePoint(firstChar, nextChar)
1614 }
1715 }
@@ -24,9 +22,9 @@ object CommonStringFunctions {
2422 if (startIndex !in text.indices) throw IndexOutOfBoundsException ()
2523
2624 val firstChar = text[startIndex]
27- if (isLowSurrogate(firstChar ) && startIndex - 1 >= 0 ) {
25+ if (firstChar. isLowSurrogate() && startIndex - 1 >= 0 ) {
2826 val previousChar = text[startIndex - 1 ]
29- if (isHighSurrogate(previousChar )) {
27+ if (previousChar. isHighSurrogate()) {
3028 return toCodePoint(previousChar, firstChar)
3129 }
3230 }
@@ -42,9 +40,9 @@ object CommonStringFunctions {
4240 do {
4341 val firstChar = text[index]
4442 index++
45- if (isHighSurrogate(firstChar ) && index < endIndex) {
43+ if (firstChar. isHighSurrogate() && index < endIndex) {
4644 val nextChar = text[index]
47- if (isLowSurrogate(nextChar )) {
45+ if (nextChar. isLowSurrogate()) {
4846 index++
4947 }
5048 }
@@ -65,9 +63,9 @@ object CommonStringFunctions {
6563 if (currentIndex > text.lastIndex) throw IndexOutOfBoundsException ()
6664 val firstChar = text[currentIndex]
6765 currentIndex++
68- if (isHighSurrogate(firstChar ) && currentIndex <= text.lastIndex) {
66+ if (firstChar. isHighSurrogate() && currentIndex <= text.lastIndex) {
6967 val nextChar = text[currentIndex]
70- if (isLowSurrogate(nextChar )) {
68+ if (nextChar. isLowSurrogate()) {
7169 currentIndex++
7270 }
7371 }
@@ -80,9 +78,9 @@ object CommonStringFunctions {
8078 if (currentIndex < 0 ) throw IndexOutOfBoundsException ()
8179 val firstChar = text[currentIndex]
8280 currentIndex--
83- if (isLowSurrogate(firstChar ) && currentIndex >= 0 ) {
81+ if (firstChar. isLowSurrogate() && currentIndex >= 0 ) {
8482 val previousChar = text[currentIndex]
85- if (isHighSurrogate(previousChar )) {
83+ if (previousChar. isHighSurrogate()) {
8684 currentIndex--
8785 }
8886 }
0 commit comments