Method: StringIO#each_codepoint
- Defined in:
- ext/stringio/stringio.c
#each_codepoint {|codepoint| ... } ⇒ self
With a block given, calls the block with each remaining codepoint in the stream; see Codepoint IO.
With no block given, returns an enumerator.
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 |
# File 'ext/stringio/stringio.c', line 1084 static VALUE strio_each_codepoint(VALUE self) { struct StringIO *ptr; rb_encoding *enc; unsigned int c; int n; RETURN_ENUMERATOR(self, 0, 0); ptr = readable(self); enc = get_enc(ptr); while ((ptr = strio_to_read(self)) != NULL) { c = rb_enc_codepoint_len(RSTRING_PTR(ptr->string)+ptr->pos, RSTRING_END(ptr->string), &n, enc); ptr->pos += n; rb_yield(UINT2NUM(c)); } return self; } |