#1037048 coreutils: od: -tc doesn't work at all?

Package:
coreutils
Source:
coreutils
Description:
GNU core utilities
Submitter:
наб
Date:
2023-06-02 18:00:04 UTC
Severity:
normal
#1037048#5
Date:
2023-06-02 17:57:03 UTC
From:
To:
Dear Maintainer,

Issue 8 Draft 3, XCU, od, OPTIONS says:
108132  −t type_string
108133    Specify one or more output types. See the EXTENDED DESCRIPTION section. The
108134    application shall ensure that the type_string option-argument is a string specifying
108135    the types to be used when writing the input data. The string shall consist of the
108136    type specification characters a, c, d, f, o, u, and x, specifying named character,
108137    character, signed decimal, floating point, octal, unsigned decimal, and
108138    hexadecimal, respectively. The type specification characters d, f, o, u, and x can be
108139    followed by an optional unsigned decimal integer that specifies the number of
108140    bytes to be transformed by each instance of the output type. The type specification
108141    character f can be followed by an optional F, D, or L indicating that the conversion
108142    should be applied to an item of type float, double, or long double, respectively.
108143    The type specification characters d, o, u, and x can be followed by an optional C, S,
108144    I, or L indicating that the conversion should be applied to an item of type char,
108145    short, int, or long, respectively. Multiple types can be concatenated within the
108146    same type_string and multiple −t options can be specified. Output lines shall be
108147    written for each type specified in the order in which the type specification
108148    characters are specified.

ENVIRONMENT VARIABLES:
108183  LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as
108184           characters (for example, single-byte as opposed to multi-byte characters in
108185           arguments and input files).

EXTENDED DESCRIPTION:
108205  The number of bytes transformed by the output type specifier c may be variable depending on
108206  the LC_CTYPE category.

108244  The type specifier character c specifies that bytes shall be interpreted as characters specified by
108245  the current setting of the LC_CTYPE locale category. Characters listed in the table in XBD
108246  Chapter 5 (on page 113) ('\\', '\a', '\b', '\f', '\n', '\r', '\t', '\v') shall be written as
108247  the corresponding escape sequences, except that <backslash> shall be written as a single
108248  <backslash> and a NUL shall be written as '\0'. Other non-printable characters shall be
108249  written as one three-digit octal number for each byte in the character. Printable multi-byte
108250  characters shall be written in the area corresponding to the first byte of the character; the two-
108251  character sequence "**" shall be written in the area corresponding to each remaining byte in the
108252  character, as an indication that the character is continued. When either the −j skip or −N count
108253  option is specified along with the c type specifier, and this results in an attempt to start or finish
108254  in the middle of a multi-byte character, the result is implementation-defined.


Why, then,
  $ od -tc
  ą
  0000000 304 205  \n
  0000003
?

It appears that od -tc is treated the same as -c,
even though they're naturally different:
108106  XSI  −c  Interpret bytes as characters specified by the current setting of the LC_CTYPE
108107           category. Certain non-graphic characters appear as C escapes: "NUL=\0",
108108           "BS=\b", "FF=\f", "NL=\n", "CR=\r", "HT=\t"; others appear as 3-digit octal
108109           numbers.
(and CHANGE HISTORY, Issue 5 says
 "In the description of the −c option, the phrase ``This is equivalent to −t c.’’ is deleted.",
 which disambiguates this clumsy spelling as "-c is btowc(), -tc is normal".)

Best,
наб