1.用汉字做字符串数组的下标
2.需要返回下标的函数
例如
    test[汉]
    test[字]

解决方案 »

  1.   

    从D8开始还就是可以使用unicode标识符。:)
      

  2.   

    不是说了可以吗。
    把以下代码保存为test.dpr,注意要unicode编码,然后在命令行执行:dcc32 test.dpr
    再运行试试。:){$APPTYPE CONSOLE}
    program test;
    type
      汉字类型=(汉, 字, 类, 型);var
      汉字数组: array[汉字类型] of string = ('汉', '字', '类', '型');
      循环变量: 汉字类型;
    begin
      for 循环变量 := 汉 to 型 do
        writeln(汉字数组[循环变量]);
    end.
      

  3.   

    Borland Delphi Version 15.0
    Copyright (c) 1983,2002 Borland Software Corporation
    test.dpr(4) Error: Illegal character in input file: '汉' ($BABA)
    test.dpr(4) Error: Illegal character in input file: '字' ($D7D6)
    test.dpr(7) Error: Illegal character in input file: '汉' ($BABA)
    test.dpr(7) Error: Illegal character in input file: '汉' ($BABA)
    test.dpr(7) Error: Data type too large: exceeds 2 GB
    test.dpr(7) Error: Number of elements differs from declaration
    test.dpr(8) Error: Illegal character in input file: '循' ($D1AD)
    test.dpr(8) Error: Illegal character in input file: '字' ($D7D6)
    test.dpr(10) Error: Illegal character in input file: '循' ($D1AD)
    test.dpr(10) Error: Illegal character in input file: '汉' ($BABA)
    test.dpr(11) Error: Illegal character in input file: '汉' ($BABA)
    test.dpr(11) Error: Illegal character in input file: '环' ($BBB7)
    test.dpr(12) Error: Expression expected but 'END' found
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      A: array[Word] of Integer;
    begin
      A[Ord(WideString('汗')[1])] := 2007;
      A[Ord(WideString('啊')[1])] := 2008;  Caption := IntToStr(A[Ord(WideString('汗')[1])] +
        A[Ord(WideString('啊')[1])]);
    end;
      

  5.   

    15.0是D7的编译器,并不支持unicode编码的源文件。
      

  6.   

    DelphiGuy() 强悍啊~不过(引用一下强哥的话),这样真的会很爽吗?
      

  7.   

    可以实现
       A['汉']的形式.不过较复杂.看一下oop开发.