I don't know how to generate a hex "0x83" character from an integer value in Java.
I need a "0x83" value to represent a letter in the Cyrillic alphabet (this letter: ѓ), in order to send it (the letter) to my printer. When converting 131 (0x83 in decimal) into hex with my converter (below) I get three numbers: 0x31, 0x33 and 0x31.
public String toHex(String arg) {
return String.format("%x", new BigInteger(arg.getBytes()));
}
I need to get 0x83 from this conversion.
To convert decimal to hexadecimal, use any of the two methods i.e. Integer. toHexString() − It returns a string representation of the integer argument as an unsigned integer in base 16. Integer.
An integer can be converted to a hexadecimal by using the string. ToString() extension method.
There is no special type of data type to store Hexadecimal values in C programming, Hexadecimal number is an integer value and you can store it in the integral type of data types (char, short or int).
If you are trying to convert integer 131 to a hex string, you can try
Integer.toHexString( 131 )
It will return "83" as String.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With