Bug #4366: UTF-8???絖??????絲????????????絖???????緇????篏???х????????眼???????ゃ??????????????
http://redmine.ruby-lang.org/issues/show/4366

起票???: Motohiro KOSAKI
??鴻????若?帥??: Open, ????綺?: Normal
??????眼??: core, Target version: 1.9.2
ruby -v: ruby 1.9.3dev (2011-02-04 trunk 30761) [x86_64-linux]

test.rb
-----------------------------------
# coding: utf-8

str="???????????????"

p str[2,17]
-----------------------------------

腟????

%  ./ruby -v test.rb
ruby 1.9.3dev (2011-02-04 trunk 30761) [x86_64-linux]
"?????????\u0000"

??с?????絲???????с????????

static char *
str_utf8_nth(const char *p, const char *e, long *nthp)
{
    long nth = *nthp;

    if ((int)SIZEOF_VALUE < e - p && (int)SIZEOF_VALUE * 2 < nth) {

                ??? e-p??ゃ?障?????絖??????激??ゅ?????sizeof(VALUE)*2??с????sizeof(VALUE) (1)

        do {
            nth -= count_utf8_lead_bytes_with_word(s);
            s++;
        } while (s < t && (int)sizeof(VALUE) <= nth);

                 ????????????while??с????do???若?? (2)

?????(1)???????s==t??????????????????????翫??(2)??????????絖????紊??????????????
count_utf8_lead_bytes_with_word()??若??????????c???????????с?????


----------------------------------------
http://redmine.ruby-lang.org