[Issue 10472] lastIndexOf(string, string) does not find single character string at beginning of string

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 26 01:18:55 PDT 2013


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



--- Comment #3 from monarchdodra at gmail.com 2013-06-26 01:18:53 PDT ---
(In reply to comment #1)
> ----
>         static if      (Char.sizeof == 1) immutable fits = c <=   0x7F;
>         else static if (Char.sizeof == 2) immutable fits = c <= 0xFFFF;
>         else immutable fits = true;
> 
>         if (fits)
>         {
>             ...
> ----

Edit: The correct condition would actually be:
> ----
        static if      (Char.sizeof == 1) immutable fits = c <=   0x7F;
        else static if (Char.sizeof == 2) immutable fits = c <= 0xD7FF ||
(0xE000 <= c && c <= 0xFFFF
        else immutable fits = true;

        if (fits)
        {
            ...
----

This would be the "most correct" condition. As stated in the pull, both:
`if (std.ascii.isAscii(c))`
`if (codeLength!Char(c) == 1)`

would also be correct.

-- 
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