PDA

Click to See Complete Forum and Search --> : [RESOLVED] Ascii value from input seems incorrect


jacsoft
Oct 4th, 2009, 07:13 AM
Hello,

I am trying to read information from the system.in. That works now. But now I am stumbling upon a nxt problem. Does the system.in not support higher ascii values or so?

I want to get the ascii value from the last character from the input. So I do this:

strG = scanner.next();
iL = strG.codePointAt(strG.length()-1);
System.out.println( iL );


Now this seems to work with normal characters. But if I insert for instance ascii value 170 or so into it (Alt+0170) then it seems to be correct in the console but it always prints 65533, which is incorrect. Anyone have any idea why those higher ascii values are not shown correctly?

(ps: Do I have to set some switch to accept ANSI or so?)

/update (until ascii 126 works, 127 gives no data, everything above 128 gives 65536)

jacsoft
Oct 4th, 2009, 07:43 AM
never mind I already solved it by changing the character set to "ISO-8859-1", so my scanner is now:

scanner = new Scanner(System.in, "ISO-8859-1");