mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-23 22:30:47 +08:00
Fix unsigned value representation
This commit is contained in:
parent
42595a37b0
commit
fb635c14bc
@ -183,8 +183,8 @@ internal operator fun ByteArray.get(range: IntRange): String = buildString {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun Byte.fixToString(): String {
|
private fun Byte.fixToString(): String {
|
||||||
return when (this.toInt()) {
|
return when (val b = this.toInt() and 0xff) {
|
||||||
in 0..15 -> "0${this.toString(16).toUpperCase()}"
|
in 0..15 -> "0${this.toString(16).toUpperCase()}"
|
||||||
else -> this.toString(16).toUpperCase()
|
else -> b.toString(16).toUpperCase()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,6 @@ internal class ExternalImageTest {
|
|||||||
fun testByteArrayGet() {
|
fun testByteArrayGet() {
|
||||||
assertEquals("0F", byteArrayOf(0x0f)[0..0])
|
assertEquals("0F", byteArrayOf(0x0f)[0..0])
|
||||||
assertEquals("10", byteArrayOf(0x10)[0..0])
|
assertEquals("10", byteArrayOf(0x10)[0..0])
|
||||||
assertEquals("0FFE", byteArrayOf(0x0F, 0xFE.toByte())[0..0])
|
assertEquals("0FFE", byteArrayOf(0x0F, 0xFE.toByte())[0..1])
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user