pull/306/head
gedoor 4 years ago
parent 663f502a92
commit 0357533a6d
  1. 14
      app/src/main/java/io/legado/app/utils/StringExtensions.kt

@ -60,12 +60,14 @@ fun String.splitNotBlank(regex: Regex, limit: Int = 0): Array<String> = run {
*/
fun String.toStringArray(): Array<String> {
var codePointIndex = 0
return Array(codePointCount(0, length)) {
substring(
codePointIndex,
offsetByCodePoints(codePointIndex, 1)
.apply { codePointIndex = this }
)
return try {
Array(codePointCount(0, length)) {
val start = codePointIndex
codePointIndex = offsetByCodePoints(start, 1)
substring(start, codePointIndex)
}
} catch (e: Exception) {
split("").toTypedArray()
}
}

Loading…
Cancel
Save