|
-
Oct 4th, 2009, 07:13 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Ascii value from input seems incorrect
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:
Code:
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)
Last edited by jacsoft; Oct 4th, 2009 at 07:30 AM.
Reason: update
Don't Hate Me Cause You Ain't Me
-
Oct 4th, 2009, 07:43 AM
#2
Thread Starter
Fanatic Member
Re: Ascii value from input seems incorrect
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");
Don't Hate Me Cause You Ain't Me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|