Re: strlen man-page misinformation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 18, 2016 at 7:42 AM, walter harms <wharms@xxxxxx> wrote:
>
>
> Am 18.02.2016 14:12, schrieb Michael Kerrisk (man-pages):
>> Hello Alan,
>>
>> On 02/03/2016 06:25 PM, Alan Aversa wrote:
>>> Hello,
>>>
>>> The 2015-08-08 strlen man-page is incorrect. Here's a diff:
>>>
>>>     --- a/man3/strlen.3
>>>     +++ b/man3/strlen.3
>>>     @@ -45,7 +45,7 @@ excluding the terminating null byte (\(aq\\0\(aq).
>>>      .SH RETURN VALUE
>>>      The
>>>      .BR strlen ()
>>>     -function returns the number of bytes in the string
>>>     +function returns the number of *characters* in the string that
>>>     precede the terminating null character
>>
>> I went for a simpler change: s/bytes/characters/
>
>
> For my understanding this is wrong. 1 character may be represented by 2 or more bytes (utf8).
> see this example, the string (test) is 3 characters long and takes 6 bytes space.
>
> did i miss something ? did the specification of character change ?

[...]

Either "bytes" or "characters" would be correct. POSIX says "bytes";
ISO C says "characters".

See the definition of "character" in C11 3.7.1:

>  bit representation that fits in a byte

On the other hand, 3.7 defines an (abstract) "character" as:

> member of a set of elements used for the organization, control,
> or representation of data

It also defines the terms "multibyte character" (a sequence of one
or more bytes representing a member of the extended character set)
and "wide character" (a value of type wchar_t).

"Bytes" is less ambiguous, but "characters" matches the wording of the
ISO C standard (and, in that context, refers to single-byte characters).

-- 
Keith Thompson <Keith.S.Thompson@xxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux