Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hexdump confusion

Tags:

hexdump

I am playing with the Unix hexdump utility. My input file is UTF-8 encoded, containing a single character ñ, which is C3 B1 in hexadecimal UTF-8.

hexdump test.txt 0000000 b1c3 0000002 

Huh? This shows B1 C3 - the inverse of what I expected! Can someone explain?

For getting the expected output I do:

hexdump -C test.txt 00000000  c3 b1                                             |..| 00000002 

I was thinking I understood encoding systems.

like image 312
zedoo Avatar asked May 17 '10 07:05

zedoo


People also ask

What is Hexdump of a file?

In computing, a hex dump is a hexadecimal view (on screen or paper) of computer data, from memory or from a computer file or storage device. Looking at a hex dump of data is usually done in the context of either debugging or reverse engineering.

How do I get out of Hexdump?

-V, --version Display version information and exit. -h, --help Display help text and exit. For each input file, hexdump sequentially copies the input to standard output, transforming the data according to the format strings specified by the -e and -f options, in the order that they were specified.

How do you read Hexdump output?

The address of a hex dump counts tracks the number of bytes in the data and offsets each line by that number. So the first line starts at offset 0, and the second line represents the number 16, which is how many bytes precede the current line.

What does Hexdump mean in Linux?

The hd or hexdump command in Linux is used to filter and display the specified files, or standard input in a human readable specified format. For example, if you want to view an executable code of a program, you can use hexdump to do so.


1 Answers

This is because hexdump defaults to using 16-bit words and you are running on a little-endian architecture. The byte sequence b1 c3 is thus interpreted as the hex word c3b1. The -C option forces hexdump to work with bytes instead of words.

like image 150
Marcelo Cantos Avatar answered Sep 21 '22 11:09

Marcelo Cantos