Skip to content

CMD hex

zplutor edited this page Oct 4, 2023 · 5 revisions

hex

Displays content of file or text in hex format.

Usage

hex [<text>] [/u8] [/u16] [/f]
    [`<position>] [~<length>]

text is the text to be displayed. If there are spaces in text, enclose it in double quotation marks ". Or use text block (press ALT+T to insert) to contain arbitrary text. If text is omitted, the content of active file will be displayed instead.

/u8, /u16 switches indicate what encoding text uses. They represent UTF-8 and UTF-16 respectively. UTF-8 is default if none of them is specified. If text is omitted and one of them is present, the active path will be treated as a text in corresponding encoding rather than a path.

/f switch indicates that text is a file path and the content of file will be displayed.

position specifies the begin position of file content to display. It is prefixed with a backtick `. The default is 0 if it is omitted.

length specifies the length of file content to display. It is prefixed with a ~. The default is 128 if it is omitted. The max supported length is 4096. Use double ~ to specify the max length, for example ~~.

Both position and length can be in decimal or hexadecimal format. Use x or 0x as prefix for hexadecimal.

Example

Display 32 bytes of the active file starts from 8:
hex `8 ~32

Display a specified text in UTF-16:
hex "This is a UTF-16 string." /u16

Display the active path in UTF-8:
hex /u8

Display a specified file:
hex C:\Windows\notepad.exe /f

Clone this wiki locally