codepage
Display or set character code page
SYNOPSIS
N/A - The codepage command does not exist as a standard standalone utility in Linux.
Character encoding settings in Linux are primarily managed through environment variables and commands related to the system's locale configuration. For example, to view current locale settings, you would use locale. To convert text between encodings, you would use iconv.
PARAMETERS
N/A
As codepage is not a standalone command, it does not have specific command-line parameters.
Parameters for managing character encoding are found within commands like locale (e.g., locale -a to list all available locales) or iconv (e.g., iconv -f <from_encoding> -t <to_encoding> <input_file>).
DESCRIPTION
The term codepage is predominantly associated with DOS and Microsoft Windows operating systems, referring to a specific character set that defines how numeric values are mapped to visible characters. In the Linux and Unix-like world, the concept of character encoding is handled more broadly and flexibly through locales and specific encoding standards like UTF-8. There is no standard, standalone Linux command named codepage. Instead, Linux systems manage character encoding as part of the locale settings (e.g., en_US.UTF-8), which dictate language, country, and character set preferences for user interfaces, data processing, and text display. Commands like locale are used to view and set these preferences, while iconv is used for converting text between different character encodings.
CAVEATS
The most significant caveat is that codepage is not a native Linux command. Users migrating from Windows environments might search for such a command, but Linux handles character encoding through a different paradigm, primarily using locales and internationalization (i18n) standards. Directly manipulating "codepages" as distinct entities is uncommon; instead, focus is placed on the broader locale which includes character set definitions, typically UTF-8 for modern systems.
MANAGING CHARACTER ENCODING IN LINUX
While codepage is not a command, here's how character encoding is typically managed:
1. Viewing Current Encoding:
To see your current character encoding, check your locale settings:
Command: locale charmap
Example output: UTF-8
2. Setting Locale and Encoding:
Locale settings, including the character encoding, are usually set in system-wide configuration files (e.g., /etc/locale.conf, /etc/environment) or user-specific files (e.g., ~/.bashrc). Environment variables like LANG and LC_ALL control the locale.
Example: export LANG="en_US.UTF-8"
3. Converting File Encodings:
The iconv command is indispensable for converting text files from one encoding to another.
Syntax: iconv -f <source_encoding> -t <destination_encoding> <input_file> -o <output_file>
Example: iconv -f ISO-8859-1 -t UTF-8 old_file.txt -o new_file.txt
HISTORY
The concept of "codepages" emerged prominently in the DOS and early Windows era to manage character sets for different languages and regions. These were often single-byte encodings (e.g., CP437 for US/Europe, CP850 for multilingual). In contrast, the Unix/Linux world adopted a more unified and extensible approach with locales and standards like ISO 8859 and later UTF-8 (Unicode Transformation Format - 8-bit). UTF-8's variable-width encoding allowed for the representation of virtually all characters in all languages, largely rendering the need for separate, region-specific "codepages" obsolete for general text handling. Modern Linux systems heavily rely on UTF-8 as the default character encoding.