Display only the character-map or encoding name used by the current LC_CTYPE.
Which command is appropriate?
locale charmap displays the current character encoding name, such as UTF-8.
Detailed explanation
locale charmapCorrect. locale charmap prints the current character-map name.
Correct. locale charmap prints the current character-map name.
locale -aIncorrect. locale -a lists installed locale names.
Incorrect. locale -a lists installed locale names.
iconv -fIncorrect. iconv -f specifies a source encoding rather than reading the current locale.
Incorrect. iconv -f specifies a source encoding rather than reading the current locale.
date +%ZIncorrect. date +%Z displays a timezone abbreviation.
Incorrect. date +%Z displays a timezone abbreviation.
Try it yourself
An example you can run in a temporary verification environment.
locale charmapExpected result
UTF-8、ANSI_X3.4-1968等の現在環境のcharacter map名Key points
- charmap is encoding name
- Related to LC_CTYPE
- Different from locale -a
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.