| Author |
Accessing Internal Represenation of a character
|
sur manickam
Greenhorn
Joined: Dec 27, 2008
Posts: 6
|
|
Hi friends, Could anyone guide me in this regard. When we declare and store a character in java, it is represented in the memory as binary, is it possible to access and change the bits from the memory directly. To get more idea about the same which topic should I read. Thanks.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
Java Mobile and regular Java are identical in this regard, so you could have asked the question in the Java (Beginner) forum and gotten the same reply, but here it is: Java uses Unicode as its internal character representation. To store in any other form (such as ASCII or EBCDIC), you'd have to store the data in a byte object and not a character/string object. Java allows upcasting characters to integers. Once you have the value as an integer, you can do all the usual integer and bit operations on that integer. To return the data to character form, you have to downcast it again. So: final int HEX10 = (int) 'A'; int hex12 = ( ((int) 'C') - HEX10 ) + 10;
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
sur manickam
Greenhorn
Joined: Dec 27, 2008
Posts: 6
|
|
|
Java uses 16 bits for each character. Low-order 8 bits stands for the ascii value. Is it possible to store some extra bits in the high-order 8 bits ?
|
 |
 |
|
|
subject: Accessing Internal Represenation of a character
|
|
|