Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1049855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:40:53+00:00 2026-05-16T16:40:53+00:00

The problem with unsigned char. I am reading a PPM image file which has

  • 0

The problem with unsigned char.
I am reading a PPM image file which has data in ASCII/Extended ASCII.

For a character, eg. ‘†’ ,
In JAVA, after reading it as char and typecasting into int its value is 8224.
In C/C++, after reading it as a unsigned char and typecasting into int its value is 160.

How would i read in JAVA so as to get value 160 ?

The followng C++

unsigned char ch1 ='†';  
char ch2 = '†';  

cout << (int) ch1 << "\n"; // prints 160  
cout << (int) ch2 << "\n"; // prints -96  

In Java,

char ch1 = '^';  
char ch2 = '†';  
System.out.println (" value : " +  (int) ch1); // prints 94  
System.out.println (" value :" +  (byte) ch1); // prints 94  

System.out.println (" value : " +  (int) ch2); // prints 8224  
System.out.println (" value :" +  (byte) ch2); // prints 32 

Following are some exceptions
8224 †
8226 •
8800 ≠
8482 ™
8710 ∆
8211 –
8221 ”
8216 ‘
9674 ◊
8260 ⁄
8249 ‹
8249 ‹
8734 ∞
8747 ∫
8364 €
8730 √
8804 ≤

Following are some good ones
94 ^
102 f
112 p
119 w
126 ~
196 Ä
122 z
197 Å
197 Å

Any help is appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:40:54+00:00Added an answer on May 16, 2026 at 4:40 pm

    In C++ you are using “narrow” characters in some specific encoding that happens to define character ‘†’ as 160. In other encodings 160 may mean something else, and character ‘†’ may be missing altogether.

    In Java, you are always dealing with Unicode. 8660 = 0x2020 = U+2020 “DAGGER”.

    To get “160”, you need to convert your string to the same encoding you are using with C++. See String.getBytes(charset).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

each source file has a function: unsigned char test(){ //return true if tests succceed
I have a very strange problem when reading a binary file. void metaDataProcess(FILE *f){
So here's the problem, I'm reading a level file for my game, works fine
Simple question, how does one create a function which takes an unsigned char std::vector
This is my problem. I am reading a file in binary mode, appending the
i have data (unsigned char data[480][640][4]) and two threads thisThread1FunctinIsCalledForExampleAbout50CallsPerSecond() { fill( data );
I am opening a 3.5 MB file in C reading it into an unsigned
C#.NET 4.0 I'm having an interesting problem here with reading a custom file archive
I'm trying to initialize a simple NSString from an unsigned char array (ASCII encoded).
In another question I had the problem to port the code: unsigned long stack[]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.