I was just trying out some very basic comprassion algorithms(hardly comprassed really) and I noaticed that whenever I input 128, the byte not the int, when I read that byte it shows up as 63. Every single time. Im using Java 5 and JCreator 3.50.011.
Here's the code I used to test.
import java.io.*;
publicclass Test
{
publicstaticvoid main(String[] args)
{
PrintWriter out;
BufferedReader in;
try
{
out = new PrintWriter(new FileOutputStream(new File("hello.txt")));
out.write(128);
out.close();
}catch(Exception e)
{
System.err.println(e);
}
try
{
in = new BufferedReader(new FileReader(new File("hello.txt")));
System.out.println(in.read());
}catch(Exception e)
{
System.err.println(e);
}
}
}
When I added a for loop to that I got 63 for every number from 128-159.
Does anyone know why this is happning? Any help is greatly appricated.
Thanks for the repley [b]javaxodus[\b]. Unfortenetly that wasn't the problem for two reasons. First it outputs all the numbers of 159 correctly. Second I tested it using -127 as the starting [b]i[\b] position and everything below 0 came out as 63 as well. Thanks for tring.
Since the first 256 code points of Unicode are based on ISO 8859-1, Unicode characters 128 to 159 are unused characters, corresponding to the upper control character set of ISO 8859-1. Even if characters in the range 128 to 159 display something sensible on your browser, they cannot be relied upon to display the same thing ? or anything at all ? on any other browser, so they should never be used.
Did you look at hello.txt? All 128-159 probably come out as question marks (128 did for me), which is Unicode 63.