telnet AIX 中文亂碼

xz43發表於2011-12-02
本地windows系統,首先登入VPN,然後透過SSH連線到linux伺服器,再用telnet登入AIX系統的Oracle資料庫伺服器。使用sqlplus命令連線資料庫,輸入和顯示中文都是亂碼。但使用系統命令 cat 和 more 檢視包含中文的檔案,中文卻能正常顯示。
 
檢視資料庫字符集
SQL> select * from v$nls_parameters;
PARAMETER                                                        VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
NLS_LANGUAGE                                                     AMERICAN
NLS_TERRITORY                                                    AMERICA
NLS_CURRENCY                                                     $
NLS_ISO_CURRENCY                                                 AMERICA
NLS_NUMERIC_CHARACTERS                                           .,
NLS_CALENDAR                                                     GREGORIAN
NLS_DATE_FORMAT                                                  DD-MON-RR
NLS_DATE_LANGUAGE                                                AMERICAN
NLS_CHARACTERSET                                                 AL32UTF8
NLS_SORT                                                         BINARY
NLS_TIME_FORMAT                                                  HH.MI.SSXFF AM
PARAMETER                                                        VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
NLS_TIMESTAMP_FORMAT                                             DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT                                               HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT                                          DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY                                                $
NLS_NCHAR_CHARACTERSET                                           AL16UTF16
NLS_COMP                                                         BINARY
NLS_LENGTH_SEMANTICS                                             BYTE
NLS_NCHAR_CONV_EXCP                                              FALSE
19 rows selected.
SQL>
SQL> select * from SYS.PROPS$;
NAME                           VALUE$                                   COMMENT$
------------------------------ ---------------------------------------- --------------------------------------------------
DICT.BASE                      2                                        dictionary base tables version #
DEFAULT_TEMP_TABLESPACE        TEMP                                     Name of default temporary tablespace
DEFAULT_PERMANENT_TABLESPACE   SYSTEM                                   Name of default permanent tablespace
DBTIMEZONE                     +08:00                                   DB time zone
DEFAULT_TBS_TYPE               SMALLFILE                                Default tablespace type
NLS_LANGUAGE                   AMERICAN                                 Language
NLS_TERRITORY                  AMERICA                                  Territory
NLS_CURRENCY                   $                                        Local currency
NLS_ISO_CURRENCY               AMERICA                                  ISO currency
NLS_NUMERIC_CHARACTERS         .,                                       Numeric characters
NLS_CHARACTERSET               AL32UTF8                                 Character set
NAME                           VALUE$                                   COMMENT$
------------------------------ ---------------------------------------- --------------------------------------------------
NLS_CALENDAR                   GREGORIAN                                Calendar system
NLS_DATE_FORMAT                DD-MON-RR                                Date format
NLS_DATE_LANGUAGE              AMERICAN                                 Date language
NLS_SORT                       BINARY                                   Linguistic definition
NLS_TIME_FORMAT                HH.MI.SSXFF AM                           Time format
NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM                 Time stamp format
NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR                       Time with timezone format
NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR             Timestamp with timezone format
NLS_DUAL_CURRENCY              $                                        Dual currency symbol
NLS_COMP                       BINARY                                   NLS comparison
NLS_LENGTH_SEMANTICS           BYTE                                     NLS length semantics
NAME                           VALUE$                                   COMMENT$
------------------------------ ---------------------------------------- --------------------------------------------------
NLS_NCHAR_CONV_EXCP            FALSE                                    NLS conversion exception
NLS_NCHAR_CHARACTERSET         AL16UTF16                                NCHAR Character set
NLS_RDBMS_VERSION              10.2.0.5.0                               RDBMS version for NLS parameters
GLOBAL_DB_NAME                 MOE                                      Global database name
EXPORT_VIEWS_VERSION           8                                        Export views revision #
WORKLOAD_CAPTURE_MODE                                                   CAPTURE implies workload capture is in progress
NO_USERID_VERIFIER_SALT        FA24F63CA895C9B7DA60C8AED997DFC1
29 rows selected.
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Data Mining and Real Application Testing options
 
透過 locale 命令檢視下系統支援的語言
$ locale -a
C
POSIX
en_US.8859-15
en_US.ISO8859-1
en_US
$
 
透過 env 命令檢視當前使用者的語言變數
$ env
_=/usr/bin/env
TMPDIR=/tmp
LANG=en_US
LOGIN=oracle
PATH=/u01/app/oracle/product/10.2.0/db_1/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/oracle/bin:/usr/bin/X11:/sbin:.
ORACLE_BASE=/u01/app/oracle
LC__FASTMSG=true
CLASSPATH=/u01/app/oracle/product/10.2.0/db_1/JRE/lib:/u01/app/oracle/product/10.2.0/db_1/JRE/lib/rt.jar:/u01/app/oracle/product/10.2.0/db_1/jlib:/u01/app/oracle/product/10.2.0/db_1/rdbms/jlib
LOGNAME=oracle
TMP=/tmp
MAIL=/usr/spool/mail/oracle
ORA_DB=/u01/app/oracle/product/10.2.0/db_1/dbs
ORACLE_SID=moe
LOCPATH=/usr/lib/nls/loc
USER=oracle
AUTHSTATE=files
TNS_ADMIN=/u01/app/oracle/product/10.2.0/db_1/network/admin
SHELL=/usr/bin/ksh
ORACLE_TERM=vt100
ODMDIR=/etc/objrepos
ORA_NLS33=/u01/app/oracle/product/10.2.0/db_1/ocommon/nls/admin/data
HOME=/home/oracle
TERM=vt100
MAILMSG=[YOU HAVE NEW MAIL]
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
PWD=/home/oracle
TZ=BEIST-8BEIDT
A__z=! LOGNAME
NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat
LIBPATH=/u01/app/oracle/product/10.2.0/db_1/lib:/u01/app/oracle/product/10.2.0/db_1/ctx/lib
LD_LIBRARY_PATH=/u01/app/oracle/product/10.2.0/db_1/lib:/usr/lib
$
 
透過 date 檢視時間判斷系統為中文還是英文系統
$ date
Fri Dec  2 14:38:01 BEIST 2011
$
 
檢視 profile 的變數設定
$ cat .profile

PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.
export PATH
if [ -s "$MAIL" ]           # This is at Shell startup.  In normal
then echo "$MAILMSG"        # operation, the Shell checks
fi                          # periodically.

umask 022
export TMP=/tmp;                    
export TMPDIR=/tmp;                 
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE                                                                           
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME                                                          
ORACLE_SID=moe; export ORACLE_SID                                                                                            
ORACLE_TERM=vt100; export ORACLE_TERM                                                                                     
TNS_ADMIN=$ORACLE_HOME/network/admin;export TNS_ADMIN                                                                     
#NLS_LANG=american_america.zhs16gbk; export NLS_LANG                                                                       
ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data; export ORA_NLS33                                                           
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib; export LD_LIBRARY_PATH                                                         
LIBPATH=$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib ;export LIBPATH                                                             
ORA_DB=$ORACLE_HOME/dbs;export ORA_DB                                                                                     
CLASSPATH=$ORACLE_HOME/JRE/lib:$ORACLE_HOME/JRE/lib/rt.jar:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH    
PATH=$ORACLE_HOME/bin:$PATH; export PATH                                                                                  
NLS_LANG="Simplified chinese_china.utf8";export NLS_LANG
$
 
原來profile裡面沒有最後一行的
NLS_LANG="Simplified chinese_china.utf8";export NLS_LANG
後來加上這行,再使用第三方工具 putty 透過telnet方式連線到資料庫,就可以正常顯示和編輯中文了。看來還真是 telnet 工具的原因,引起的中文亂碼了。
 
不知道是否有其他解決辦法,而不使用putty工具。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9399028/viewspace-712633/,如需轉載,請註明出處,否則將追究法律責任。

相關文章