Method: StringIO#getc
- Defined in:
- ext/stringio/stringio.c
#getc ⇒ nil
Reads and returns the next character from the stream; see Character IO.
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
# File 'ext/stringio/stringio.c', line 864 static VALUE strio_getc(VALUE self) { struct StringIO *ptr = readable(self); rb_encoding *enc = get_enc(ptr); VALUE str = ptr->string; long pos = ptr->pos; int len; char *p; if (pos >= RSTRING_LEN(str)) { return Qnil; } p = RSTRING_PTR(str)+pos; len = rb_enc_mbclen(p, RSTRING_END(str), enc); ptr->pos += len; return enc_subseq(str, pos, len, enc); } |