私は以下の簡単なプログラムを書いて、hello をアラビア語で出力しました:"سلام" しかし、コンソールでの出力は正しくありません:
import static java.lang.Integer.toBinaryString;
import java.util.Arrays;
public class testOfPrintln {
public static void main(String []strings){
String test="salam";
String test2="سلام";//unicode , arabic
byte []strbytes=test.getBytes();
int i=1;
for(byte bb:strbytes)
System.out.println(i++ + " -> " + bb);
byte []strbytes2=test2.getBytes();
i=1;
for(byte bb2:strbytes2){
System.out.println(i++ + " -> " + bb2);
}
}
}
そして出力:
1 -> 115
2 -> 97
3 -> 108
4 -> 97
5 -> 109
1 -> -40
2 -> -77
3 -> -39
4 -> -124
5 -> -40
6 -> -89
7 -> -39
8 -> -123
バイトの前に「-」文字があるのはなぜですか? 例: -123 tnx。