od
seems not changing anything, but iconv
does. According to your output, this system maps utf-16
to utf-16be
.
Compare with output from my Ubuntu on x86-64:
$ echo hello | iconv -f ascii -t utf-16le | hd
00000000 68 00 65 00 6c 00 6c 00 6f 00 0a 00 |h.e.l.l.o...|
0000000c
$ echo hello | iconv -f ascii -t utf-16le | od -x
0000000 0068 0065 006c 006c 006f 000a
0000014
$ echo hello | iconv -f ascii -t utf-16be | hd
00000000 00 68 00 65 00 6c 00 6c 00 6f 00 0a |.h.e.l.l.o..|
0000000c
$ echo hello | iconv -f ascii -t utf-16be | od -x
0000000 6800 6500 6c00 6c00 6f00 0a00
0000014
One could call od -t x1
instead of hd
with similar output:
$ echo hello | iconv -f ascii -t utf-16be | od -t x1
0000000 00 68 00 65 00 6c 00 6c 00 6f 00 0a
0000014
it's like hd
but without ASCII column.
But my Ubuntu maps utf-16 to utf-16le with BOM:
$ echo hello | iconv -f ascii -t utf-16 | od -x
0000000 feff 0068 0065 006c 006c 006f 000a
0000016
$ echo hello | iconv -f ascii -t utf-16 | hd
00000000 ff fe 68 00 65 00 6c 00 6c 00 6f 00 0a 00 |..h.e.l.l.o...|
0000000e
that is interesting why your OS X system is configured opposite way. I see no real reason for this; maybe it is some weird legacy or compile configuration error. Does it have documentation with mentioning of this moment?
od -t x1
(so printing a byte at a time) or you will get an additional conversion (which may confuse you) – Giacomo Catenazzi Jul 21 '20 at 15:08