File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes Accessing Internal Represenation of a character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Accessing Internal Represenation of a character" Watch "Accessing Internal Represenation of a character" New topic
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: 15960
    
  19

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 ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing Internal Represenation of a character
 
Similar Threads
String and boolean memory
Serialised session size
WA #1.....word association
Declaration difference
split method in java