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