The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


2 byte character vs single byte character

Posted by Matt Gerrans on January 09, 2002 at 5:59 PM

> Hi ,
> how do we find whether a character is 2 byte character or a single byte character

char is always a two-byte data type. Are you trying to find out whether a given character is unicode or ascii? If all but the bottom 7 bits are zero, it is ascii, eg.:

boolean isAscii( char c )
return (c & 0xff80) == 0;

You could change this to include extended ascii by checking against 0xff00.


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us