Good afternoon, you need to send data to the server in format 16 of the river system ASCII. For example, -1 as FFFFFFFF respectively, -2 as FFFFFFFE
What is this fff ? How to convert int a =-1 to FFFFFFFF ?
Thanks for attention
Good afternoon, you need to send data to the server in format 16 of the river system ASCII. For example, -1 as FFFFFFFF respectively, -2 as FFFFFFFE
What is this fff ? How to convert int a =-1 to FFFFFFFF ?
Thanks for attention
This type of record is called an additional code . In Java, you can get such an entry by standard means:
Integer.toHexString(1); // 1 Integer.toHexString(2); // 2 Integer.toHexString(-1); // ffffffff Integer.toHexString(-2); // fffffffe If you need to write positive numbers to the left with zeros up to 8 characters, help String.format() :
String.format("%8s", Integer.toHexString(123)).replace(' ', '0') // 0000007b String.format("%08x", 123) ? - zRrr 4:02 pmThe easiest way
int a =-1; System.out.println(Integer.toHexString(a)); In java so
String input = ... // my UTF-16 string StringBuilder sb = new StringBuilder(input.length()); for (int i = 0; i < input.length(); i++) { char ch = input.charAt(i); if (ch <= 0xFF) { sb.append(ch); } } byte[] ascii = sb.toString().getBytes("ISO-8859-1"); // aka LATIN-1 input = "-1" , what happens? - IgorSource: https://ru.stackoverflow.com/questions/813352/
All Articles