permaculture playing cards*
The moose likes Beginning Java and the fly likes why char data of two bytes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why char data of two bytes." Watch "why char data of two bytes." New topic
Author

why char data of two bytes.

Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
why sun microsystem given a character has a 2bytes capacity.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3615
    
  14

How many bytes would you use?
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
Stephan van Hulst wrote:How many bytes would you use?



char takes one byte for each character then why he given char as a 2 bytes.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7696
    
  20

Ritesh raushan wrote:char takes one byte for each character...

Says who? You've plainly discovered that in Java, it doesn't.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3615
    
  14

If a character was only one byte, you could have no more than 256 characters. The latin alphabet alone uses 24 letters and 10 digits. What about all the other languages with their alphabets and special letters and symbols? There is no way you can represent them all with only one byte.

With two bytes, you can represent 65.536 characters. This seems much more adequate.
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
thanks stephen.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why char data of two bytes.