How to Fix SQL*Plus Garbled Characters: Master OS, Client, and Oracle Charsets
This guide explains the three essential character sets—operating system (LANG), Oracle database (NLS_CHARACTERSET), and client (NLS_LANG)—and provides step‑by‑step instructions with screenshots to resolve SQL*Plus display garbling issues.
Character Set Overview
Three related character sets affect Oracle client display:
Operating system charset – controlled by the LANG environment variable on the client machine. It must be a superset of the database charset; otherwise characters may appear garbled.
Database charset – defined by the NLS_CHARACTERSET parameter. Query with
SELECT value FROM nls_database_parameters WHERE parameter='NLS_CHARACTERSET';. Changing it is only safe when the new charset is a strict superset (e.g., UTF8 → AL32UTF8).
Client charset – defined by NLS_LANG. If unset, the client inherits the default value from the Oracle installation.
Prerequisite: Verify Subset‑Superset Relationship
Oracle documentation lists valid binary subset‑superset pairs (e.g., WE8MSWIN1252 ⊂ AL32UTF8). Ensure the OS charset, NLS_LANG, and NLS_CHARACTERSET belong to the same family.
Step‑by‑Step Procedure (Linux client)
1. Check the OS charset
localeThe output shows the current LANG value, e.g., en_US.UTF-8.
2. Install Chinese language support (if missing)
If the system lacks Chinese locale packages, setting LANG alone will not enable Chinese rendering.
3. Add Chinese support via YUM
sudo yum -y groupinstall "chinese-support"After installation, Chinese characters can be displayed correctly.
4. Test with two Oracle instances
Two databases are used for demonstration: PROD1 – charset WE8MSWIN1252 (Western European). PROD5 – charset AL32UTF8 (Unicode).
When NLS_LANG is unset, the client inherits the installation defaults ( AMERICAN_AMERICA.WE8MSWIN1252 for PROD1, SIMPLIFIED CHINESE_CHINA.AL32UTF8 for PROD5).
5. Resolve garbled Chinese on PROD5
Initially PROD5 shows unreadable Chinese characters while PROD1 displays English correctly. Set NLS_LANG to match the database charset:
export NLS_LANG=SIMPLIFIED_CHINESE_CHINA.AL32UTF8After exporting the variable, Chinese text is rendered properly.
Conclusion
The client‑side display of Oracle data is governed by NLS_LANG. When Chinese characters appear garbled, first confirm that the database NLS_CHARACTERSET supports Chinese (e.g., AL32UTF8 or ZHS16GBK). If the database charset does not support the language, no client configuration can render the characters correctly. Refer to Oracle’s official “Binary Subset‑Superset Pairs” documentation for supported encodings.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
