Your current output shows all locale variables set to zh_CN.GBK encoding. This legacy Chinese encoding can cause problems with: - Modern web applications - Database systems expecting UTF-8 - File processing scripts - Internationalization tools First verify available UTF-8 locales on your system:
# locale -a | grep zh_CN.utf8 zh_CN.utf8 zh_CN.UTF-8
If missing, generate them:
# localedef -i zh_CN -f UTF-8 zh_CN.UTF-8
For testing purposes, you can temporarily switch to UTF-8:
# export LANG=zh_CN.UTF-8 # export LC_ALL=zh_CN.UTF-8
Verify with:
# locale | grep -E 'LANG|LC_'
For CentOS 5.5, edit these files:
1. System-wide default (affects new users):
# vi /etc/sysconfig/i18n LANG="zh_CN.UTF-8" LC_ALL="zh_CN.UTF-8"
2. User-specific override (in ~/.bashrc):
export LANG=zh_CN.UTF-8 export LC_ALL=zh_CN.UTF-8
After changes, verify with:
# locale # locale -k LC_CTYPE | grep charmap
Common issues:
- Missing locale packages:yum groupinstall "Chinese Support"
- SSH session caching: Start new session after changes
- Service restart requirements: Some daemons need restartSome applications may require additional configuration:
For Apache:
AddDefaultCharset UTF-8
For MySQL:
[client] default-character-set=utf8 [mysqld] character-set-server=utf8 collation-server=utf8_general_ci
For PHP:
default_charset = "UTF-8" mbstring.internal_encoding=UTF-8 mbstring.http_output=UTF-8
When working with internationalization on CentOS 5.5, you might encounter Chinese character encoding issues if your system uses GBK encoding instead of UTF-8. Here's a typical locale output showing GBK configuration:
LANG=zh_CN.GBK LC_CTYPE="zh_CN.GBK" LC_NUMERIC="zh_CN.GBK" LC_TIME="zh_CN.GBK" LC_COLLATE="zh_CN.GBK" LC_MONETARY="zh_CN.GBK" LC_MESSAGES="zh_CN.GBK" LC_PAPER="zh_CN.GBK" LC_NAME="zh_CN.GBK" LC_ADDRESS="zh_CN.GBK" LC_TELEPHONE="zh_CN.GBK" LC_MEASUREMENT="zh_CN.GBK" LC_IDENTIFICATION="zh_CN.GBK" LC_ALL=
First, verify available UTF-8 locales and generate if necessary:
# Check available locales locale -a | grep zh_CN # Generate UTF-8 locale if not present sudo localedef -v -c -i zh_CN -f UTF-8 zh_CN.UTF-8
Edit the system locale configuration file:
sudo vi /etc/sysconfig/i18n
Modify the content to:
LANG="zh_CN.UTF-8" SUPPORTED="zh_CN.UTF-8:zh_CN:zh" SYSFONT="latarcyrheb-sun16"
For immediate effect in current session (without reboot):
source /etc/sysconfig/i18n
To verify the changes:
locale
For individual users who need UTF-8 without changing system defaults:
echo 'export LANG=zh_CN.UTF-8' >> ~/.bashrc echo 'export LC_ALL=zh_CN.UTF-8' >> ~/.bashrc source ~/.bashrc
If you encounter issues after changing locale settings:
- Check if the UTF-8 locale is properly generated with
locale -a
- Verify file permissions on /etc/sysconfig/i18n
- Restart terminal sessions or SSH connections
- For applications requiring specific encoding, set LC_CTYPE individually
When changing system locale in CentOS 5.5:
- Some legacy applications might have compatibility issues with UTF-8
- Existing files with GBK encoding won't automatically convert
- System logs and cron jobs may be affected by locale changes
- Consider testing changes in a development environment first