UTF-8. , \ufffd ( REPLACEMENT CHARACTER) " , Unicode."
: , . byte ñ UTF-8, US-ASCII; ISO-8859-1. , , , String.
public class Hello {
public static void main(String[] args)
throws java.io.UnsupportedEncodingException {
String s = "Hola, señor!";
System.out.println(s);
byte[] b = new byte[s.length()];
for (int i = 0; i < b.length; i++) {
int cp = s.codePointAt(i);
b[i] = (byte) cp;
System.out.print((byte) cp + " ");
}
System.out.println();
System.out.println(new String(b, "UTF-8"));
System.out.println(new String(b, "US-ASCII"));
System.out.println(new String(b, "ISO-8859-1"));
}
}
:
Hola, señor!
72 111 108 97 44 32 115 101 -15 111 114 33
Hola, se or!
Hola, se or!
Hola, señor!