Re: Console reader?
Patrick Niemeyer <[email protected]> Tue, 24 May 2005 22:00:18 -0500
| Newsgroups | gmane.comp.java.beanshell.devel |
|---|---|
| Message-ID | <[email protected]> |
On May 23, 2005, at 2:35 AM, Dawid Weiss wrote: > A student of mine asked why Console.getIn() returns a Reader > instance that emits Java-encoded character sequences (unicode > \uxxxx) and I honestly didn't have any idea (an output stream I'd > understand, but a Reader?). What's the purpose of this and what's > the correct way to decode the stream (I advised to use > bsh.JavaCharStream to decode it, but I am still curious about this > design rationale). Well, the console interface is what the Interpreter uses to talk to the outside world. Having it return a reader for input to the interpreter/parser abstracts us from the encoding. The JavaCharStream Reader is generated by the JavaCC parser generator and used internally by the parser... In our code we simply supply a plain Reader. I'm not entirely sure why JavaCC needs to escape the unicode sequences for its own purposes. This came about when they switched from a byte stream to a Reader a long time ago. Pat ------------------------------------------------------- This SF.Net email is sponsored by Yahoo. Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005