I've been trying for hours now to figure out why, when enter a char like Ø in the console through the scanner, to then get the numeric value, I always end up with 65533 (Max value of unsigned short)?
This doesn't seem to be the case for latin characters. Any idea why?
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char[] chars = sc.next().toCharArray();
for(int i = 0; i < chars.length; i++){
System.out.println((int)chars[i]);
}
}
65533 = Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD)
i.e. Your character is not being interpreted correctly within the character encoding you are using, and so is being replaced by the fallback value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With