Re: g_utf8_validate() and NUL characters
- From: Dan Winship <danw gnome org>
- To: Behdad Esfahbod <behdad behdad org>
- Cc: Maciej Katafiasz <mathrick gmail com>, gtk-devel-list gnome org
- Subject: Re: g_utf8_validate() and NUL characters
- Date: Thu, 09 Oct 2008 09:35:15 -0400
Behdad Esfahbod wrote:
>> Sure, but then there's memcpy, memcmp, memdup, etc for the other behavior.
And they take "void *", not "char *", to indicate this fact.
I'm not arguing that a "validate UTF-8 bytes possibly including NULs"
function wouldn't be useful to some people, I'm just arguing that
g_utf8_validate() shouldn't be that function, because g_utf8_validate()
works on strings, and strings end at NUL.
> Lemme repeat again: When dealing with UTF-8 text, a max-length makes zero
> sense without inspecting the string first. So the strncpy, etc behavior is
> not relevant.
Not always true. You might do something like:
if (!g_utf8_validate (string, strcspn (string, "/"))) {
(to validate to the end of the string, or the first "/", whichever comes
first).
But at any rate, even if it was true, that would be an argument for
"g_utf8_validate() shouldn't have a length argument at all", not
"g_utf8_validate() should behave differently from other string methods
when you pass it a length".
-- Dan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]