Re: Mixing text and binary I/O
"Stefan Ram" <ram@zedat.fu-berlin.de> wrote in message
news:Iterator-20060827181829@ram.dialup.fu-berlin.de...
"Mike Schilling" <mscottschilling@hotmail.com> writes:
/** @returns a character in the range 0 to 65535, or -1 at EOF
* @param moreDecoded returns true if another character is available
without consuming more bytes
*/
int readChar(out boolean moreDecoded);
As it is, I suppose a moreDecoded() method is the least of evils, i.e.
better than forcing the client to check that the returned character is in
the range D800-DBFF.
Possibly, the Java SE way would be to implement the following interface.
I don't think so. An Iterator knows when there's nothing more to return.
Part of the assumption here is that the client knows (based on the protocol
definition) how many characters to ask for before switching back to binary.
There's nothing to tell the Iterator that.
Unless you mean that each call to readChar() returns an
Iterator<Character>. But that seems awfully cumbersome, both for the
implementation, which has to wrap each decoded char into a Character and
then wrap *that* in an Iterator, and for the client which has to unwrap each
of those..