Hex to Ascii? Java -
I am looking for a way to convert ascii to Java from hex. One example:
byte temps [] = new byte [4]; Temps [0] = 0x74; Temps [1] = 0x65; Temps [2] = 0x73; Temps [3] = 0x74; String foo = .. (temps); System.out.print (foo);
Should this production be "test" any thoughts?
I appreciate every help!
What do you mean?
But see those encodings! You are taking a set of bytes and you need to specify how to encode them as characters. You can use one of the above versions that uses a default encoding, but (depending on your application) that can give you a reason to down the line, I normally specify an encoding I am (usually UTF-8).
I specify the byte-to-ASCII, so I have explicitly used ASCII encoding charset.US-ASCII
. Do not trust encoding, which makes your JVM!
Comments
Post a Comment