Display only the encoding name used by the current locale.
Which command is appropriate?
locale charmap prints the character-map name associated with the current LC_CTYPE locale.
Detailed explanation
locale -aIncorrect. -a lists locale names.
Incorrect. -a lists locale names.
locale -mIncorrect. -m lists available character maps.
Incorrect. -m lists available character maps.
locale charmapCorrect. It prints the current character-map name.
Correct. It prints the current character-map name.
iconv -lIncorrect. iconv -l lists all conversion encodings.
Incorrect. iconv -l lists all conversion encodings.
Try it yourself
An example you can run in a temporary verification environment.
locale charmapExpected result
UTF-8など現在の文字コード名Key points
- charmap is the current encoding
- -m lists available maps
- Related to LC_CTYPE
Notes
- Environment: POSIX locale / 読み取りのみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.