Why does writeBytes discard each character in eight bits?

I wanted to use DataOutputStream # writeBytes , but ran into errors. Description writeBytes(String)from Java documentation:

Writes a string to the underlying output stream as a sequence of bytes. Each character in the string is written out sequentially, discarding its high eight bits.

I think the problem I am having is that it is "dropping its high eight bits". What does this mean and why does it work?

+4
source share
2 answers

ASCII, , Java String - 16- Unicode. writeBytes , ASCII/ISO-8859-1 "" C.

+6

char - Unicode 16-bit. '\u0000' ( 0) '\uffff' ( 65,535 ). byte - 8-bit, . -128 127 (). char . . , , , 0 255.

writeUTF(String s), , . 2- int 0 65,535. UTF-8 . , , .

+2

All Articles