[Issue 10732] New: Example code for std.utf.toUTFindex does not work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 30 18:58:51 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10732

           Summary: Example code for std.utf.toUTFindex does not work
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2013-07-30 18:58:50 PDT ---
As the title.

import std.utf;
void main()
{
  assert(toUTFindex(`hello world`, 7) == 7);    // doesn't work!
  assert(toUTFindex(`hello world`w, 7) == 7);
  assert(toUTFindex(`hello world`d, 7) == 7);

  assert(toUTFindex(`Ma Chérie`, 6) == 7);      // doesn't work!
  assert(toUTFindex(`Ma Chérie`w, 7) == 7);
  assert(toUTFindex(`Ma Chérie`d, 7) == 7);

  assert(toUTFindex(`さいごの果実 / ミツバチと科学者`, 3) == 9);  // doesn't work!
  assert(toUTFindex(`さいごの果実 / ミツバチと科学者`w, 9) == 9);
  assert(toUTFindex(`さいごの果実 / ミツバチと科学者`d, 9) == 9);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list