問題描述
我不知道如何從 Java 中的整數值生成十六進制0x83"字符.
I don't know how to generate a hex "0x83" character from an integer value in Java.
我需要一個0x83"值來表示西里爾字母中的一個字母(該字母:?),以便將它(該字母)發送到我的打印機.當使用我的轉換器(如下)將 131(十進制的 0x83)轉換為十六進制時,我得到三個數字:0x31、0x33 和 0x31.
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()));
}
我需要從這個轉換中得到 0x83.
I need to get 0x83 from this conversion.
推薦答案
如果你正在嘗試將整數 131 轉換為十六進制字符串,你可以試試
If you are trying to convert integer 131 to a hex string, you can try
Integer.toHexString( 131 )
它將以字符串形式返回83".
It will return "83" as String.
這篇關于如何從 Java 中的十進制整數中獲取十六進制值?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!