• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help to output unsigned byte > 127

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
AND-ing with 0xFF and casting (implicitly or explicitly) to an int does the trick.



Prints

144
90
 
Louie van Bommel
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope



As you can see (above new results line), it still prints out a ?, not the � (capital E with accent)
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic