Commit fb635c14 authored by Him188's avatar Him188

Fix unsigned value representation

parent 42595a37
......@@ -183,8 +183,8 @@ internal operator fun ByteArray.get(range: IntRange): String = buildString {
}
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()}"
else -> this.toString(16).toUpperCase()
else -> b.toString(16).toUpperCase()
}
}
\ No newline at end of file
......@@ -9,6 +9,6 @@ internal class ExternalImageTest {
fun testByteArrayGet() {
assertEquals("0F", byteArrayOf(0x0f)[0..0])
assertEquals("10", byteArrayOf(0x10)[0..0])
assertEquals("0FFE", byteArrayOf(0x0F, 0xFE.toByte())[0..0])
assertEquals("0FFE", byteArrayOf(0x0F, 0xFE.toByte())[0..1])
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment