Bug 218600 - printf family returns number of bytes written, not characters
Summary: printf family returns number of bytes written, not characters
Status: RESOLVED CODE_FIX
Alias: None
Product: Documentation
Classification: Unclassified
Component: man-pages (show other bugs)
Hardware: All Linux
: P3 low
Assignee: documentation_man-pages@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-14 22:16 UTC by qbl
Modified: 2024-03-15 23:33 UTC (History)
1 user (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description qbl 2024-03-14 22:16:38 UTC
For comparison:
https://pubs.opengroup.org/onlinepubs/9699919799/

In an utf8 environment the number of bytes written may differ
from the number of characters.

Example:
fprintf( stdout, "%*s\n", fprintf( stdout, "öäüÖÄÜßµł€\n"), "^");

From https://man7.org/linux/man-pages/man3/dprintf.3.html:
"Upon successful return, these functions return the number of
 characters printed (excluding the null byte used to end output to
 strings)."

Greetings.
Comment 1 Alejandro Colomar 2024-03-15 23:33:18 UTC
Thanks!  This has been fixed now:

<https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=e0fc7ee5e3d664c83bd0f4fc751ef80cf38ae1bc>

Have a lovely day!
Alex

Note You need to log in before you can comment on or make changes to this bug.