Transfer byte to char in Java - in CMD -


if transfer byte char in java, have following problem:

in netbeans o.k., if run program windows cmd have problem charset. don't know why.

what do?

code:

char tmp = (byte) charfrombyteint; // it's byte in int variable 

guessed on output image it's charset problem.

following snippet return same byte values input string.

string teststring = "test stackoverflow";  byte[] bytes = teststring.getbytes(standardcharsets.utf_8); system.out.println("bytes = " + arrays.tostring(bytes));  bytes = teststring.getbytes(standardcharsets.iso_8859_1); system.out.println("bytes = " + arrays.tostring(bytes)); 

output

bytes = [84, 69, 83, 84, 32, 102, 111, 114, 32, 115, 116, 97, 99, 107, \          111, 118, 101, 114, 102, 108, 111, 119] 

as output in console generates more characters in input string, should check source (from take byte / int values) output.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -