[Bluej-discuss] Terminal Window in 2.1.2...
Davin McCall
davmac at bluej.org
Fri Mar 24 03:18:45 GMT 2006
I made a mistake in my previous post; it is NOT, in fact, normally
necessary to use an OutputStreamWriter to send characters to the
terminal. That is, it's not necessary to do:
/
/ Writer w = new OutputStreamWriter(System.out, "UTF-8");
... Just to output characters (including non-Latin-1 characters) to the
terminal.
Todd O'Bryan suggested:
> That would be kind of annoying, since all the System.out.println()
> statements wouldn't work. Could you instead do something like
>
> System.setOut(new PrintStream(System.out, true, "UTF-8");
>
> once at the beginning of your application. Then all the System.out
> calls would still work, I think.
>
... And this in fact is what is done "behind the scenes" by BlueJ
(versions 2.1.0 and up).
So, I do not understand why you don't see the correct output.
However:
- Reading characters from the terminal may require constructing an
InputStreamReader and specifying the UTF-8 encoding. Using System.in in
the normal way may not work correctly. Unfortunately there is no way to
make this work automatically.
- If an OutputStreamWriter for the terminal is constructed at any point,
it must specify a UTF-8 encoding seeing as that is the encoding that is
actually used.
Either of these issues may be responsible for the incorrect output.
Davin
Rudolf PECINOVSKÝ wrote:
>> Writer w = new OutputStreamWrite(System.out, "UTF-8");
>> w.write("Hello\n");
>>
>
> May be I am dumb, but I yet do not understand, why this necessity is not hidden inside
> BlueJ.
> Why it is pulled out into its interface and therefore we need to explain it to our
> students?
> I think it violates the encapsulation.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bluej.org/pipermail/bluej-discuss/attachments/20060324/17a68da9/attachment-0001.html
More information about the bluej-discuss
mailing list