oracle 让 SQLPlus 后台处理出 Unicode 字符,输出为?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7179181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:16:13  来源:igfitidea点击:

Getting SQLPlus to spool out Unicode characters, are being output as?

oracleutf-8oracle10gsqlplus

提问by Todd Allen

I am attempting to get Oracle sqlplus (10.2) to spool out Unicode data on a Linux machine. I have found several discussions of this issue, but no clear answers, other than to check locale settings and set NLS_LANG to AL32UTF8. All locale info is set to "en_US.UTF-8", I'll post the full output upon request.

我试图让 Oracle sqlplus (10.2) 在 Linux 机器上假脱机出 Unicode 数据。我发现了一些关于这个问题的讨论,但没有明确的答案,除了检查区域设置并将 NLS_LANG 设置为 AL32UTF8。所有语言环境信息都设置为“en_US.UTF-8”,我会根据要求发布完整的输出。

The OS (vi, etc.), will recognize and accept Unicode characters without issue. However, when using sqlplus, all non-ASCII characters are changed to ? characters. The Oracle DB has NLS_CHARACTERSET set to AL32UTF8, and NLS_NCHAR_CHARACTERSET set to AL16UTF16.

操作系统(vi 等)将毫无问题地识别和接受 Unicode 字符。但是,在使用 sqlplus 时,所有非 ASCII 字符都更改为 ? 人物。Oracle DB 将 NLS_CHARACTERSET 设置为 AL32UTF8,将 NLS_NCHAR_CHARACTERSET 设置为 AL16UTF16。

Am I missing some setting or switch that needs to be set for sqlplus itself? Any ideas would be much appreciated.

我是否缺少一些需要为 sqlplus 本身设置的设置或开关?任何想法将不胜感激。

回答by Todd Allen

I found the answer to this. Apparently, setting NLS_LANG (the correct setting is AMERICAS_AMERICA.AL32UTF8) in the shell script does not work. It must be exported:

我找到了这个问题的答案。显然,在 shell 脚本中设置 NLS_LANG(正确的设置是 AMERICAS_AMERICA.AL32UTF8)不起作用。它必须导出:

export NLS_LANG=AMERICAN_AMERICA.AL32UTF8