method
chars
v1_8_7_72 -
Show latest stable
- Class:
StringIO
chars()public
See IO#each_char.
/*
* call-seq:
* strio.each_char {|char| block } -> strio
*
* See IO#each_char.
*/
static VALUE
strio_each_char(self)
VALUE self;
{
struct StringIO *sio;
VALUE str;
const char *ptr;
size_t len;
RETURN_ENUMERATOR(self, 0, 0);
sio = readable(StringIO(self));
str = sio->string;
ptr = RSTRING_PTR(str);
len = RSTRING_LEN(str);
while (sio->pos < len) {
int pos = sio->pos;
char c = ptr[pos];
int n = mbclen(c);
if (len < pos + n) n = len - pos;
sio->pos += n;
rb_yield(rb_str_substr(str, pos, n));
}
return self;
} Related methods
- Instance methods
- <<
- binmode
- bytes
- chars
- close
- close_read
- close_write
- closed?
- closed_read?
- closed_write?
- each
- each_byte
- each_char
- each_line
- eof
- eof
- eof?
- eof?
- fcntl
- fileno
- flush
- fsync
- getbyte
- getc
- gets
- initialize_copy
- isatty
- length
- lineno
- lineno=
- lines
- path
- pid
- pos
- pos
- pos=
- printf
- putc
- puts
- read
- readbyte
- readchar
- readline
- readline
- readlines
- reopen
- rewind
- rewind
- seek
- seek
- size
- string
- string=
- sync
- sync=
- sysread
- syswrite
- tell
- truncate
- tty?
- ungetc
- write
- Class methods
- new
- new
- open