-
@ ever4st
2025-01-23 13:59:37-
UTF-16 Encoding: The
echo
command in a DOS environment (like the command prompt) typically defaults to writing output to a file using UTF-16 encoding. -
Byte Order Mark (BOM): UTF-16 uses a Byte Order Mark (BOM) at the beginning of the file to indicate the endianness (byte order) of the encoding.
- FF FE: This specific byte order (FF FE) signifies little-endian encoding, where the least significant byte of each 16-bit code unit comes first.
-
2 Coding Pairs: In UTF-16, each character is represented by two bytes (a code unit).
Example:
- Execution:
- Open a command prompt window.
- Type the following command:
echo "something" > file.txt
-
Press Enter.
-
File Contents:
- The
file.txt
will be created with the following:- FF FE: BOM for little-endian UTF-16.
- Two bytes representing the letter 's'.
- Two bytes representing the letter 'o'.
- And so on, for each character in "something".
Note:
- The specific behavior might vary slightly depending on the exact version of Windows and the regional settings.
- You can often configure the command prompt to use different encodings, such as UTF-8, if needed.
-