unsignedcharの問題。ASCII/拡張ASCIIのデータを含むPPM画像ファイルを読んでいます。
キャラクターの場合、例えば。'†'、JAVAでは、charとして読み取り、intに型キャストした後、その値は8224です。C/ C ++では、unsigned charとして読み取り、intに型キャストした後、その値は160です。
値160を取得するためにJAVAを読み取るにはどうすればよいですか?
次のC++
unsigned char ch1 ='†';
char ch2 = '†';
cout << (int) ch1 << "\n"; // prints 160
cout << (int) ch2 << "\n"; // prints -96
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
以下にいくつかの例外を示します。8224†8226•8800≠8482™8710∆ 8211 – 8221” 8216 '9674◊8260⁄ 8249 ‹8249 ‹8734∞8747∫8364€8730√8804≤
以下はいくつかの良いものです94^102 f 112 p 119 w 126〜196Ä122z197Å197Å
どんな助けでも大歓迎です