upperCase
Defines HexFormat.upperCase of the format being built, false
by default.
Refer to HexFormat.upperCase for details about how the format option affects the formatting results.
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
// By default, upperCase is set to false, so lower-case hexadecimal digits are used when formatting.
println(58.toHexString()) // 0000003a
println(58.toHexString(HexFormat.Default)) // 0000003a
// Setting upperCase to true changes the hexadecimal digits to upper-case.
println(58.toHexString(HexFormat { upperCase = true })) // 0000003A
println(58.toHexString(HexFormat.UpperCase)) // 0000003A
// The upperCase option affects only the case of hexadecimal digits.
val format = HexFormat {
upperCase = true
number.prefix = "0x"
}
println(58.toHexString(format)) // 0x0000003A
// The upperCase option also affects how byte arrays are formatted.
println(byteArrayOf(0x1b, 0xe6.toByte()).toHexString(format)) // 1BE6
// The upperCase option does not affect parsing; parsing is always case-insensitive.
println("0x0000003a".hexToInt(format)) // 58
println("\"1BE6\".hexToByteArray(format).contentEquals(byteArrayOf(0x1b, 0xe6.toByte())) is ${"1BE6".hexToByteArray(format).contentEquals(byteArrayOf(0x1b, 0xe6.toByte()))}") // true
//sampleEnd
}