read Stdin() - > string- 모듈
- std.
io → - 수신자
- 해당 없음
- 최소 인자 수
- 0
- 최대 인자 수
- 0
Declaration and parameters
링크사용 조건
기본 포함 · 미정
Import std.io in language mode 5.21.
The current compiler selects std/io.tpz for this language mode. Availability in other released editions and inclusion in each installed distribution are Pending.
수신자
매개변수 제약
read reads the remaining standard input bytes through EOF. UTF-8 validity and text preservation follow UTF-8 decoding. It does not append or remove a newline.
No remaining bytes produces an empty string. A later call reads from the stream position left by the earlier call and therefore returns an empty string at EOF. A terminal follows the same EOF rule as redirected input.
The call may wait for input or EOF. Reading consumes input even when the result is later discarded. A host read failure or invalid UTF-8 produces a structured runtime fault at the readStdin call because the function returns a string rather than a Result.
The Topaz 6.0 host input fault is TPZ4008. Its primary location is the readStdin call.
관련 규칙 · Read standard input through its end →결과
The declared result type is string.
효과
실패
Result and effects
링크Consume the remaining standard input through EOF as strict UTF-8 text. Preserve whitespace and return empty text when no bytes remain.
Related entries
링크Read standard input through its end
링크Read standard input through its end
read reads the remaining standard input bytes through EOF. UTF-8 validity and text preservation follow UTF-8 decoding. It does not append or remove a newline.
No remaining bytes produces an empty string. A later call reads from the stream position left by the earlier call and therefore returns an empty string at EOF. A terminal follows the same EOF rule as redirected input.
The call may wait for input or EOF. Reading consumes input even when the result is later discarded. A host read failure or invalid UTF-8 produces a structured runtime fault at the readStdin call because the function returns a string rather than a Result.
The Topaz 6.0 host input fault is TPZ4008. Its primary location is the readStdin call.
이유
Standard input is a stream shared with the host. Consuming it once gives EOF one meaning and lets terminal and redirected input obey the same rule. Strict UTF-8 prevents malformed bytes from silently becoming different text.
Preserve redirected text and its line endings
링크import std.iolet text = io.readStdin()io.writeLine(text)
alpha
한글
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
alpha한글
Return empty text at an empty input stream
링크import std.iolet text = io.readStdin()let empty = text == ""io.writeLine("{empty}")
true
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
true
Observe EOF after standard input has been consumed
링크import std.iolet first = io.readStdin()let second = io.readStdin()let atEnd = second == ""io.writeLine(first)io.writeLine("{atEnd}")
alpha
true
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
alphatrue