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> { fun String.toStringArray(): Array<String> {
var codePointIndex = 0 var codePointIndex = 0
return Array(codePointCount(0, length)) { return try {
substring( Array(codePointCount(0, length)) {
codePointIndex, val start = codePointIndex
offsetByCodePoints(codePointIndex, 1) codePointIndex = offsetByCodePoints(start, 1)
.apply { codePointIndex = this } substring(start, codePointIndex)
) }
} catch (e: Exception) {
split("").toTypedArray()
} }
} }

Loading…
Cancel
Save