fix unicode handling for peekchar, return eof for readchar instead of throwing an error