Why does writeBytes discard each character's high eight bits?

java

Solution

Most Western programmers tend to think in terms of ASCII, where one character equals one byte, but Java `String`s are 16-bit Unicode. `writeBytes` just writes out the lower byte, which for ASCII/ISO-8859-1 is the "character" in the C sense.

Problem

I wanted to use DataOutputStream#writeBytes, but was running into errors. Description of `writeBytes(String)` from the Java Documentation: Writes out the string to the underlying output stream as a sequence of bytes. Each character in the string is written out, in sequence, by discarding its high eight bits. I think the problem I'm running into is due to the part about "discarding its high eight bits". What does that mean, and why does it work that way?

Original source