본문으로 건너뛰기
토파즈6.0 · 출시 전
다운로드 →

문서 검색

명세 6.0

방향키로 결과를 고르고 Enter를 눌러 여세요.

API 이름, 진단 번호, 규칙 또는 프로젝트 주제를 입력하세요.

    라이브러리

    std.io.readStdin

    Reads from standard input.

    readStdin() -> string
    수신자
    해당 없음
    최소 인자 수
    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.

    수신자

    매개변수 제약

    readStdin 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.

    결과

    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

    링크

    std.io →

    Read standard input through its end

    링크
    규칙topaz.stdlib.contract.stdin-consumption.rule

    Read standard input through its end

    readStdin 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

    링크
    main.tpzPreserve redirected text and its line endings플레이그라운드 열기 →
    1. import std.io
    2. let text = io.readStdin()
    3. io.writeLine(text)
    기대 출력종료 코드 0
      alpha
    한글
    
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. alpha
    2. 한글

    Return empty text at an empty input stream

    링크
    main.tpzReturn empty text at an empty input stream플레이그라운드 열기 →
    1. import std.io
    2. let text = io.readStdin()
    3. let empty = text == ""
    4. io.writeLine("{empty}")
    기대 출력종료 코드 0
    true
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. true

    Observe EOF after standard input has been consumed

    링크
    main.tpzObserve EOF after standard input has been consumed플레이그라운드 열기 →
    1. import std.io
    2. let first = io.readStdin()
    3. let second = io.readStdin()
    4. let atEnd = second == ""
    5. io.writeLine(first)
    6. io.writeLine("{atEnd}")
    기대 출력종료 코드 0
    alpha
    true
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. alpha
    2. true

    메뉴

    다운로드 →