Prior, to Java 1.5.x, any character is internally represented as a 16-bit Unicode character using the UTF-16 encoding. As of JDK 1.5.x, changes have been made to support the use of surrogate (16-bit) pairs as well.
True "ASCII" characters only require 7 bits.
Regards, JD [ August 26, 2006: Message edited by: John Dell'Oso ]
Joined: Apr 16, 2005
there is no premetive type in java which holds 7-bits ?
so it might be 8 bits coz byte is a primitive which can hold 1 ascii char
I am fully aware that there is no 7-bit primitive data type in Java. To be honest, your question was a bit vague to start with. You asked about the size of an ASCII character in Java, so I assumed you were referring to the char data type. If this is the case then I stand by my original response.
The reference to ASCII characters only requiring 7-bits means that according to the "standard", the ASCII character set only requires 7 bits to fully represent all of these characters. However, internally within Java they are still represented as 16-bits when using the char data type.
In the past, many vendors made use of the high order 8th bit for their own proprietary purposes and this caused more trouble than it was worth - hence the birth of Unicode.
Nowadays, I would tend to avoid using terms such as "ASCII" and "plain text". These are "historical" terms that are biased towards the mapping of characters in the English (Latin) language only.
There is a plethora of information on the net about this subject and here's a link to the Unicode website if you require more information: