From 0357533a6d301ba83cc667552c945d4896b4473a Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 14 Aug 2020 12:21:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/utils/StringExtensions.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/StringExtensions.kt b/app/src/main/java/io/legado/app/utils/StringExtensions.kt index 3c2703311..76a8536fc 100644 --- a/app/src/main/java/io/legado/app/utils/StringExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/StringExtensions.kt @@ -60,12 +60,14 @@ fun String.splitNotBlank(regex: Regex, limit: Int = 0): Array = run { */ fun String.toStringArray(): Array { 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() } }