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.
locale -mIncorrect. -m lists available character maps.
locale charmapCorrect. It prints the current character-map name.
iconv -lIncorrect. 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
Locale category
A setting that controls language, numeric formatting, collation, or date display.
Character encoding
A mapping between characters and the bytes used to represent them.
Timezone
A rule set that converts timestamps for a region or display context.