aspose file tools
The moose likes Java in General and the fly likes Need help to output unsigned byte > 127 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Need help to output unsigned byte > 127" Watch "Need help to output unsigned byte > 127" New topic
Author

Need help to output unsigned byte > 127

Louie van Bommel
Ranch Hand

Joined: Aug 17, 2004
Posts: 76
I can't seem to do this, as you can see in my code. It's supposed to output a value of 0x90 but it outputs a value of 0x5B when I look at the results of my output in a binary/hex dump.


it's supposed to show a capital E with an accent but it shows a question mark. When I spew the output to a file and look at that file in a hex dump, the value of that question mark is 0x5B (or 91 decimal). it should be 144 decimal or 0x90.

Q: how do I do an output statement correctly? The specs require me to write out unsigned byte data to a file with values of 144 and such.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24057
    
  13

AND-ing with 0xFF and casting (implicitly or explicitly) to an int does the trick.



Prints

144
90


[Jess in Action][AskingGoodQuestions]
Louie van Bommel
Ranch Hand

Joined: Aug 17, 2004
Posts: 76
Nope



As you can see (above new results line), it still prints out a ?, not the � (capital E with accent)
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
It looks like the decimal and hex values are what you want (144 and 0x90, respectively), correct? I suspect that your operating system doesn't want to print Unicode characters in the console window. What version of Windows are you running?

Layne


Java API Documentation
The Java Tutorial
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24057
    
  13

Originally posted by Louie van Bommel:
Nope


I've shown you how to recover the correct hex value. Displaying the character is another thing altogether. As Layne says, your OS has to be configured with the right code page to show non-ASCII characters. You may have better luck in a Swing window than you will at a console window.

Note that Mozilla on my machine, which properly displays Japanese, Chinese, Korean, Cyrillic, Hebrew, and all sorts of exotic scripts, prints "?" for 0x90, too.

So in what character set is 0x90 an E with an accent? in all of the ISO8859 sets, 0x90 is a non-printing character.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help to output unsigned byte > 127
 
Similar Threads
Right shift using array
Correctly specified Identifiers
A doubt in bitwise operator
Sign extension doubt?
To Hex String and back...