假设有
S ='一';
如何得到S的拼音?
谁有思路?难不成要列举所有的拼音?

解决方案 »

  1.   

    用Delphi 6编程实现自动标注汉语拼音
     出处:电脑爱好者
    责任编辑:zwg
     
    [02-3-25 16:42]  作者:Daffodil  
    程序代码如下:
    unit Unit1; 
    interface 
    uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
    StdCtrls, ExtCtrls, Buttons, IMM; type TForm1 = class(TForm) OpenDialog1: TOpenDialog; BitBtn2: TBitBtn; BitBtn3: TBitBtn; Edit2: TEdit; Edit1: TEdit; Label5: TLabel; Label1: TLabel; BitBtn1: TBitBtn; procedure BitBtn1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure BitBtn3Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); public iHandleCount: integer; pList : array[1..20] of HKL; szImeName : array[0..254] of char; II : integer; end; 
    const pych: array[1..6,1..5] of string[2]= (('ā', 'á','ǎ','à','a'),('ō', 'ó','ǒ','ò','o'), ('ē', 'é','ě','è','e'),('ī', 'í','ǐ','ì','i'), ('ū', 'ú','ǔ','ù','u'),('ǖ', 'ǘ','ǚ','ǜ','ü')); 
    var Form1: TForm1; 
    implementation 
    {$R *.DFM} 
    procedure TForm1.FormCreate(Sender: TObject); var i: integer; begin II := 0; //retrieves the keyboard layout handles corresponding to the current set of input locales in the system. iHandleCount := GetKeyboardLayoutList(20, pList); for i := 1 to iHandleCount do begin if ImmEscape(pList[i], 0, IME_ESC_IME_NAME, @szImeName) > 0 then if szImeName='微软拼音输入法' then begin 
    StdCtrls, ExtCtrls, Buttons, IMM; type TForm1 = class(TForm) OpenDialog1: TOpenDialog; BitBtn2: TBitBtn; BitBtn3: TBitBtn; Edit2: TEdit; Edit1: TEdit; Label5: TLabel; Label1: TLabel; BitBtn1: TBitBtn; procedure BitBtn1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure BitBtn3Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); public iHandleCount: integer; pList : array[1..20] of HKL; szImeName : array[0..254] of char; II : integer; end; 
    const pych: array[1..6,1..5] of string[2]= (('ā', 'á','ǎ','à','a'),('ō', 'ó','ǒ','ò','o'), ('ē', 'é','ě','è','e'),('ī', 'í','ǐ','ì','i'), ('ū', 'ú','ǔ','ù','u'),('ǖ', 'ǘ','ǚ','ǜ','ü')); 
    var Form1: TForm1; 
    implementation 
    {$R *.DFM} 
    procedure TForm1.FormCreate(Sender: TObject); var i: integer; begin II := 0; //retrieves the keyboard layout handles corresponding to the current set of input locales in the system. iHandleCount := GetKeyboardLayoutList(20, pList); for i := 1 to iHandleCount do begin if ImmEscape(pList[i], 0, IME_ESC_IME_NAME, @szImeName) > 0 then if szImeName='微软拼音输入法' then begin 
    ii := i; exit; end; end; ShowMessage('请你安装"微软拼音输入法"!'); end;
      

  2.   

    **************
    金山词霸(2.0-2000版本)内有gb2py.idx和gbk2py.idx,内有国标
    GB、GBK的每个汉字的拼音和声调。可用拿来一用。下面上Delphi写的gb2py函数。
    function gb2py(hanzi:pchar):pchar;
    var
    Sfile:Tmemorystream;
    pos,temp,ipos,len:integer;
    py:array[0..20] of char;
    begin
      pos:=($fe-$a1)*(ord(hanzi[0])-$b0)+ord(hanzi[1])-$a1;
      sfile:=Tmemorystream.create;
      sfile.loadfromfile('C:\Program Files\KINGSOFT\XDICT\gb2py.idx');
      //data:=sfile.memory;
      sfile.Seek($1608+pos*4,soFromBeginning);
      sfile.Read(ipos,4);
      sfile.Read(temp,4);
      len:=temp-ipos;
      sfile.Seek(ipos+1,soFromBeginning);
      sfile.Read(py,len);
      py[len-1]:=#0;
      sfile.Free;
      result:=py;
    end; 
    来自超级猛料