-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
Hi,
Many thanks for your work !!!
just used the utf8Validate function in glib/Unicode.d module
GtkD/generated/gtkd/glib/Unicode.d
Line 1468 in 3ae4282
| public static bool utf8Validate(string str, out string end) |
In my understanding end should be made of the chars from start of str to outend, outend beeing the first invalid char in str or pointing after the last char of str if valid.
At the moment the function is "returning" the chars from outend to the end of str or nothing.
public static bool utf8Validate(string str, out string end)
{
char* start = Str.toStringz(str), outend = null;
auto __p = g_utf8_validate(start, cast(ptrdiff_t)str.length, &outend) != 0;
end = Str.toString(start, outend - start);
return __p;
}
unittest
{
string valid;
bool success = Unicode.utf8Validate("random text", valid);
assert(success);
assert(valid == "random text");
success = Unicode.utf8Validate("random \xc3\x28text", valid);
assert(!success);
assert(valid == "random ");
success = Unicode.utf8ValidateLen("random text", valid);
assert(success);
assert(valid == "random text");
success = Unicode.utf8ValidateLen("random \xc3\x28text", valid);
assert(!success);
assert(valid == "random ");
}Same goes for utf8ValidateLen() as seen in the unittest.
(code is a fixed proposal - for brevity passing tests with non literal string were omitted )
Did i miss something ?
Cheers
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels