On Fri, 30 Oct 2020, Sven Schreiber wrote:
Am 12.10.2020 um 19:24 schrieb Sven Schreiber:
> Am 06.10.2020 um 15:28 schrieb Allin Cottrell:
>>
>> And talking about undocumented extensions, maybe we should mention
>> that nelem() can be applied to strings, in which case it returns the
>> number of bytes as opposed to the number of UTF-8 characters. Or we
>> could get rid of that.
>>
> I think it would be good (and easy) to just add a note to the strlen
> information, where it currently is silent about how to actually count
> the bytes. No reason to scrap it AFAICS.
>
Are you guys OK with an additional sentence in the 'strlen' reference
like this: "If you actually wish to count the number of bytes that the
string takes, you can use the 'nelem' function."
I could add that.
I would rephrase this as follows:
(current version)
Note that this does not equal the number of bytes if some characters are
outside of the printable-ASCII range.
(proposal)
Note that this does not equal the number of bytes if some characters are
outside of the printable-ASCII range; if this is what you want, you can
use the nelem() function.
and maybe add an example:
<hansl>
string s = "¡Olé!"
printf "strlen(s) = %d, nelem(s) = %d\n", strlen(s), nelem(s)
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------