Jakub, Thank you very much for sharing this. I found a confirmation to that (that the `char` is 1 byte) in the Standards and updated my records at https://github.com/kuzminrobin/code_review_notes/blob/master/cpp_design_bookmarks.md#distinguish-between-size-and-length (starting with "is 1 byte in size"). I apologize for troubling. Robin Kuzmin kuzmin.robin@xxxxxxxxx On Wed, Jul 11, 2018 at 3:57 PM, Jakub Wilk <jwilk@xxxxxxxxx> wrote: > * Robin Kuzmin <kuzmin.robin@xxxxxxxxx>, 2018-07-11, 09:56: >> >> I see: >> The strncpy() function is similar, except that at most n **bytes** of >> src are copied >> I expected: >> The strncpy() function is similar, except that at most n **characters** >> of src are copied >> >> The difference is important because if the `char` size (in bytes) is >> different from 1 byte on some implementation then "the number of characters" >> and "the number of bytes" are different. > > > This is a common misconception about the C language. No, the size of char is > always exactly one byte. (Now, that byte might be wider than 8 bits the > people are used to, but that's a different story...) > >> The confirmation to my words is in C99: >> 7.21.2.4 The strncpy function >> The strncpy function copies not more than n **characters** ... > > > In C99, "character" is another name for "single-byte character". > > On the other hand, in POSIX lingo, "character" means multi-byte character. > > POSIX uses the term "byte" in their definitions of strncpy and similar > functions, which is compatible with C99 and unambiguous. Linux man pages > should do the same. > > -- > Jakub Wilk -- 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