<div>Does anyone see any problems with this patch?</div><div>If everything is OK, I will commit this patch around next sunday.</div><div><br></div><div><br></div><div>Masahiro</div><div><br></div><div class="gmail_quote">2010年11月14日15:27 Masahiro Nakagawa <span dir="ltr"><<a href="mailto:repeatedly@gmail.com">repeatedly@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Current std.utf is bit messy and lacks attributes, so I wrote a patch.<br>
This patch passes Phobos's unittests.<br>
<br>
Changes:<br>
<br>
* Remove UtfError<br>
<br>
UtfError has been depreacated since Phobos 0.140 (from revision log on dsource).<br>
I think removing UtfError is no problem.<br>
<br>
* Add @safe, @trusted, pure and nothrow attributes<br>
<br>
I think Unicode operations should be @safe and pure, but dependent functions are not.<br>
So, some functions are @trusted and not pure.<br>
<br>
* char version of stride<br>
<br>
I removed assert because the comment says "0xFF meaning s[i] is not the start of of UTF-8 sequence.".<br>
Until now, my library checked 0xFF :(<br>
<br>
* validate<br>
<br>
Add constraint.<br>
<br>
* toUTF* functions<br>
<br>
Unify the argument type using 'in'.<br>
Current implementation is mixed with "in char[]" and "const(char)[]".<br>
<br>
Remove some functions that take string, wstring and dstring.<br>
The body of these functions call validate only. Need?<br>
<br>
* count supports dchar<br>
<br>
I wrote following code in my library.<br>
<br>
static if (is(Char == dchar))<br>
immutable num = text.length;<br>
else<br>
immutable num = text.count();<br>
<br>
Why doesn't count support dchar?<br>
<br>
In addition, Why does count depend walkLength?<br>
count's call graph is:<br>
<br>
std.utf.count -> std.range.walkLength -> std.array.empty, front, popFront -> std.utf.stride<br>
<br>
This seems to be weird. I think count itself calculates the total number of code points and<br>
walkLength depends count is more better. The patch doesn't include this proposal.<br>
<br>
What do you think?<br><font color="#888888">
<br>
<br>
Masahiro</font></blockquote></div><br>