@JRubyMethod(name = "each_codepoint") public IRubyObject each_codepoint(ThreadContext context, Block block) { Ruby runtime = context.runtime; if (!block.isGiven()) return enumeratorize(runtime, this, "each_codepoint"); checkReadable(); Encoding enc = ptr.string.getEncoding(); byte[] unsafeBytes = ptr.string.getByteList().getUnsafeBytes(); int begin = ptr.string.getByteList().getBegin(); for (; ; ) { if (ptr.pos >= ptr.string.size()) { return this; } int c = StringSupport.codePoint(runtime, enc, unsafeBytes, begin + ptr.pos, unsafeBytes.length); int n = StringSupport.codeLength(runtime, enc, c); block.yield(context, runtime.newFixnum(c)); ptr.pos += n; } }