Skip to content

What is correct behavior of Stdin.readCodepoint? #127

@joshgoebel

Description

@joshgoebel

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions