为什么小写 'i' 映射到 '?'完成后 NLS_UPPER

Why lowercase 'i' mapped to '?' after doing NLS_UPPER

有人可以解释为什么字符串 abcdefghijklmnopqrstuvwxyz 中的小写 i 被映射到 ? 而所有其他字母都正确映射到相应的大写字母。

SQL> ALTER SESSION SET NLS_SORT="xturkish";

Session altered.

SQL> 
SQL> begin
  2   DBMS_OUTPUT.PUT_LINE('NLS_UPPER(abcdefghijklmnopqrstuvwxyz) = '
  3                || NLS_UPPER('abcdefghijklmnopqrstuvwxyz'));
  4  end;
  5  /
NLS_UPPER(abcdefghijklmnopqrstuvwxyz) = ABCDEFGH?JKLMNOPQRSTUVWXYZ

PL/SQL procedure successfully completed.

SQL> 

更新:如果 nls_sort 设置为 BINARY,则映射按预期发生,小写字母 i 映射到平面英语字母表 I

我无法解释,因为我无法重现。你的机器一定有问题。这是我的会话,从 SQL*Plus:

复制粘贴
SQL> set serveroutput on
SQL> ALTER SESSION SET NLS_SORT="xturkish";

Session altered.

Elapsed: 00:00:00.01
SQL> begin
  2     DBMS_OUTPUT.PUT_LINE('NLS_UPPER(abcdefghijklmnopqrstuvwxyz) = '
  3                  || NLS_UPPER('abcdefghijklmnopqrstuvwxyz'));
  4    end;
  5  /
NLS_UPPER(abcdefghijklmnopqrstuvwxyz) = ABCDEFGHIJKLMNOPQRSTUVWXYZ

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.00
SQL>

土耳其语的大写 iİ(U+0130:带点的拉丁文大写字母 I),参见 https://codepoints.net/U+0130

The Turkish alphabet, which is a variant of the Latin alphabet, includes two distinct versions of the letter I, one dotted and the other dotless.

The dotless I, I ı, denotes the close back unrounded vowel sound (/ɯ/). Neither the upper nor the lower case version has a dot.

The dotted I, İ i, denotes the close front unrounded vowel sound (/i/). Both the upper and lower case versions have a dot.

Examples:

  • İstanbul /isˈtanbuɫ/ (starts with an i sound, not an ı).

  • Diyarbakır /dijaɾˈbakɯɾ/ (the first and last vowels are spelled and pronounced differently)

看来你的数据库字符集不支持这个字符,请问你的数据库字符集是什么?检查

SELECT * 
FROM V$NLS_PARAMETERS 
WHERE PARAMETER IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET');

我假设

DBMS_OUTPUT.PUT_LINE('NLS_UPPER(abcdefghijklmnopqrstuvwxyz) = '
   || NLS_UPPER(N'abcdefghijklmnopqrstuvwxyz')); 

应该可以。

您必须正确设置 NLS_LANG 和控制台代码页才能正确输出。以下是一些工作示例:

C:\>set NLS_LANG=.AL32UTF8
C:\>chcp 65001
Active code page: 65001

C:\>sqlplus ...
select nls_upper('i', 'nls_sort = xturkish') from dual;



C:\>set NLS_LANG=.TR8MSWIN1254
C:\>chcp 1254
Active code page: 1254

C:\>sqlplus ...
select nls_upper('i', 'nls_sort = xturkish') from dual;




C:\>set NLS_LANG=.SE8ISO8859P3
C:\>chcp 28593
Active code page: 28593

C:\>sqlplus ...
select nls_upper('i', 'nls_sort = xturkish') from dual;




C:\>set NLS_LANG=.WE8ISO8859P9
C:\>chcp 28599
Active code page: 28599

C:\>sqlplus ...
select nls_upper('i', 'nls_sort = xturkish') from dual;