Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is correct behavior of Stdin.readCodepoint? #127

Open
joshgoebel opened this issue Sep 24, 2021 · 0 comments
Open

What is correct behavior of Stdin.readCodepoint? #127

joshgoebel opened this issue Sep 24, 2021 · 0 comments

Comments

@joshgoebel
Copy link
Contributor

joshgoebel commented Sep 24, 2021

Related: #71

This PR seems necessary for Unicode support in the REPL, so I think it's fair to ask how it should behave in the edge cases, when a stream is terminated with an incomplete code point.

  • First let me say that like readByte I assume if there are multiple codePoints still in the buffer then calling readCodepoint would continue to read them out one by one until the EOF is hit... please correct me if anyone disagrees.
  • I assume if the the input stream is still open and we have an incomplete code point in the buffer that we'd go async and wait for more input to complete the code point. (just like we go for waiting for a fill line with readLine)

LIke the other read methods, when EOF is hit the question is abort or return null.

The last interesting question here is if we get to the end of the input stream (it closes) and only have "half a character" left.

  • Should we just return a short string of gibberish (invalid Unicode)?
  • Should this raise an error itself?
  • Should the invalid half character be silently dropped?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant