Method: IO#getc
- Defined in:
- io.c
permalink #getc ⇒ nil
Reads and returns the next 1-character string from the stream; returns nil
if already at end-of-stream. See Character IO.
f = File.open('t.txt')
f.getc # => "F"
f.close
f = File.open('t.rus')
f.getc.ord # => 1090
f.close
Related: IO#readchar (may raise EOFError).
5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 |
# File 'io.c', line 5015
static VALUE
rb_io_getc(VALUE io)
{
rb_io_t *fptr;
rb_encoding *enc;
GetOpenFile(io, fptr);
rb_io_check_char_readable(fptr);
enc = io_input_encoding(fptr);
READ_CHECK(fptr);
return io_getc(fptr, enc);
}
|