<p dir="auto">The <code class="notranslate">peek</code> function is very useful and an efficient alternative to marking and resetting a stream when all you need to do is get a single character. The current <code class="notranslate">peek</code> returns a byte, however, which leads to errors when people assume that they can compare that byte to a character and check for a character (only works for UTF-8 streams and ASCII characters). This was a significant annoyance in implementing <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="150595994" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/16024" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/16024/hovercard" href="https://github.com/JuliaLang/julia/pull/16024">#16024</a>. This is technically not breaking since <code class="notranslate">Base.peek</code> isn't exported. Most code that uses it will actually continue to work.</p>
<p dir="auto">As discussed here: <a href="https://groups.google.com/forum/?fromgroups=#!topic/julia-users/kDKL1dS4L0w" rel="nofollow">https://groups.google.com/forum/?fromgroups=#!topic/julia-users/kDKL1dS4L0w</a></p>
<p dir="auto">Basically, I'd like to be able to peek at the first few characters of an IO stream, without removing the characters from the stream.  In particular, it needs to work with streams that are not files and therefore not seekable.</p>