[Issue 5257] std.algorithm.count works incorrectly with UTF8 and UTF16 strings

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 22 12:30:09 PST 2010


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


jakobovrum at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakobovrum at gmail.com


--- Comment #2 from jakobovrum at gmail.com 2010-11-22 12:28:48 PST ---
This is almost entirely off-topic, but I don't think such a tiny change
deserves its own issue... sorry if I should have :(

When this gets fixed, count() will be useful as a generic way to count the
amount of code points in a UTF encoded string. But I don't think the interface
is very pretty for this simple use case.

As a completely non-breaking change, how about changing:
size_t count(alias pred, Range)(Range r) if (isInputRange!(Range))

to:
size_t count(alias pred = "true", Range)(Range r) if (isInputRange!(Range))

So one could simply do count("日本語")?

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