mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-23 22:30:47 +08:00
Make chinese letter length estimating more safer
This commit is contained in:
parent
7abfa5a0af
commit
069753e9c2
@ -32,7 +32,7 @@ internal fun Int.toIpV4AddressString(): String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun String.chineseLength(upTo: Int): Int {
|
internal fun String.chineseLength(upTo: Int): Int {
|
||||||
return this.sumUpTo(upTo) { if (it in '\u0391'..'\uFFE5') 3 else 1 }
|
return this.sumUpTo(upTo) { if (it in '\u0391'..'\uFFE5') 4 else 1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun MessageChain.estimateLength(upTo: Int = Int.MAX_VALUE): Int =
|
internal fun MessageChain.estimateLength(upTo: Int = Int.MAX_VALUE): Int =
|
||||||
|
Loading…
Reference in New Issue
Block a user