linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Keith Thompson <keithsthompson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: wharms-fPG8STNUNVg@public.gmane.org
Cc: "Michael Kerrisk (man-pages)"
	<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Alan Aversa <alan.aversa-j9pdmedNgrk@public.gmane.org>,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: strlen man-page misinformation
Date: Thu, 18 Feb 2016 08:25:56 -0800	[thread overview]
Message-ID: <CAAHpriPqJhR45MD9C1cstZO_f=x92kB4ro0kosSEGb+aoc2MHw@mail.gmail.com> (raw)
In-Reply-To: <56C5E67A.2010401-fPG8STNUNVg@public.gmane.org>

On Thu, Feb 18, 2016 at 7:42 AM, walter harms <wharms-fPG8STNUNVg@public.gmane.org> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2016-02-18 16:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <56B237F9.8010206@cox.net>
     [not found] ` <56B237F9.8010206-j9pdmedNgrk@public.gmane.org>
2016-02-18 13:12   ` strlen man-page misinformation Michael Kerrisk (man-pages)
     [not found]     ` <56C5C33E.7030407-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-02-18 15:42       ` walter harms
     [not found]         ` <56C5E67A.2010401-fPG8STNUNVg@public.gmane.org>
2016-02-18 16:25           ` Keith Thompson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAHpriPqJhR45MD9C1cstZO_f=x92kB4ro0kosSEGb+aoc2MHw@mail.gmail.com' \
    --to=keithsthompson-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=alan.aversa-j9pdmedNgrk@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=wharms-fPG8STNUNVg@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).