如只要輸入'組件':就可以得到ZJ
  人民郵電;得到rmyd
 各位高手有沒有什么辦法!

解决方案 »

  1.   

    获取一个汉字的拼音首字    
      ///////////////////////////////////////////////////////////////////////////// 
    // FileName: PY.pas//// Copyright (C) 1999 By Zhang Qing//// You can use and modify it ,but please send me an email.//// E-Mail: [email protected]/////////////////////////////////////////////////////////////////////////////unit PY;interfaceuses sysutils;// 获取汉字的拼音首字符,这个函数将用在GetPYIndexStr 中.function GetPYIndexChar(strChinese: string; bUpCase: Boolean = True): char;// 获取多个汉字的拼音首字符组成的字符串.function GetPYIndexStr(strChinese: string; bUpCase: Boolean = True): string;implementation////////////////////////////////////////////////////////////////////////////// 函数: GetPYIndexChar(strChinese: string;bUpCase: Boolean = True): char;//// 函数功能:获取汉字的拼音首字符.// 例: GetPYIndexChar('程') 将返回'C'.//// 注意:对于多于一个汉字的输入(string类型)只有第一个有效,但不会产生错误// 例如,GetPYIndexChar('程序')也将返回'C'.//// 第二个参数决定返回大写还是小写 , 缺省为大写 .////////////////////////////////////////////////////////////////////////////function GetPYIndexChar(strChinese: string;bUpCase: Boolean = True): char;begin// 根据汉字表中拼音首字符分别为“A”至“Z”的汉字内码范围,// 要检索的汉字只需要检查它的内码位于哪一个首字符的范围内,// 就可以判断出它的拼音首字符。case WORD(strChinese[1]) shl 8 + WORD(strChinese[2]) of$B0A1..$B0C4 : result := 'A';$B0C5..$B2C0 : result := 'B';$B2C1..$B4ED : result := 'C';$B4EE..$B6E9 : result := 'D';$B6EA..$B7A1 : result := 'E';$B7A2..$B8C0 : result := 'F';$B8C1..$B9FD : result := 'G';$B9FE..$BBF6 : result := 'H';$BBF7..$BFA5 : result := 'J';$BFA6..$C0AB : result := 'K';$C0AC..$C2E7 : result := 'L';$C2E8..$C4C2 : result := 'M';$C4C3..$C5B5 : result := 'N';$C5B6..$C5BD : result := 'O';$C5BE..$C6D9 : result := 'P';$C6DA..$C8BA : result := 'Q';$C8BB..$C8F5 : result := 'R';$C8F6..$CBF9 : result := 'S';$CBFA..$CDD9 : result := 'T';$CDDA..$CEF3 : result := 'W';$CEF4..$D188 : result := 'X';$D1B9..$D4D0 : result := 'Y';$D4D1..$D7F9 : result := 'Z';elseresult := char(0);end;if not bUpCase thenbegin // 转换为小写result := Chr(Ord(result)+32);end;end;////////////////////////////////////////////////////////////////////////////// 函数: GetPYIndexStr(strChinese: string;bUpCase: Boolean = True): string;//// 函数功能:获取多个汉字的拼音首字符组成的字符串.// 例: GetPYIndexStr('程') 将返回'C'.// GetPYIndexStr('程序')将返回'CX'.//// 第二个参数决定返回大写还是小写 , 缺省为大写 .////////////////////////////////////////////////////////////////////////////function GetPYIndexStr(strChinese: string;bUpCase: Boolean = True): string;varstrChineseTemp : string;cTemp : Char;beginresult := '';strChineseTemp := strChinese;while strChineseTemp<>'' dobegincTemp := GetPYIndexChar(strChineseTemp);if not bUpCase thenbegin // 转换为小写cTemp := Chr(Ord(cTemp)+32);end;result := result + string(cTemp);strChineseTemp := Copy(strChineseTemp,3,Length(strChineseTemp));end;end;end. 
     
       
      

  2.   

    楼上的方法不全,有很多汉字都查询不出来!to:jackie168(三箭齐发),不好意思,我以前也用过这种方法,但很多字都不能生成,后来在网上又找了一个方法,代码很长,贴不上来!
      

  3.   

    麻烦hqhhh(枫叶)发一份给我,[email protected]谢谢。
      

  4.   

    谢谢 qinzuozhang(半途香)的拼音汉字组件hqhhh(枫叶)能把你的也发给我吗?谢谢[email protected]
      

  5.   

    我也要一份谢谢。 [email protected]
      

  6.   

    能给我一份吗?
    [email protected]
    谢谢.
      

  7.   

    function GetHzPy(const AHzStr: string): string;
    const
      ChinaCode: array[0..25, 0..1] of Integer = ((1601, 1636), (1637, 1832), (1833, 2077),
        (2078, 2273), (2274, 2301), (2302, 2432), (2433, 2593), (2594, 2786), (9999, 0000),
        (2787, 3105), (3106, 3211), (3212, 3471), (3472, 3634), (3635, 3722), (3723, 3729),
        (3730, 3857), (3858, 4026), (4027, 4085), (4086, 4389), (4390, 4557), (9999, 0000),
        (9999, 0000), (4558, 4683), (4684, 4924), (4925, 5248), (5249, 5589));
    var
      i, j, HzOrd: integer;
    begin
      i := 1;
      while i <= Length(AHzStr) do
      begin
        if (AHzStr[i] >= #160) and (AHzStr[i + 1] >= #160) then
        begin
          HzOrd := (Ord(AHzStr[i]) - 160) * 100 + Ord(AHzStr[i + 1]) - 160;
          for j := 0 to 25 do
          begin
            if (HzOrd >= ChinaCode[j][0]) and (HzOrd <= ChinaCode[j][1]) then
            begin
              Result := Result + char(byte('A') + j);//改A为a就全部是小写
              break;
            end;
          end;
          Inc(i);
        end else Result := Result + AHzStr[i];
        Inc(i);
      end;
    end;
      

  8.   

    唉。我的朋友有个很棒的DLL,源码公开,不过用C写的。你们用不到……
      

  9.   

    GB2312字符集是按音序排列的,所以根据内码就可以得到。如果是GBK里面就不都是按音序来排列的,按部首或别的什么就比较麻烦,一定要有码表才行
      

  10.   

    我的QQ是161964848.  hqhhh(枫叶)發給我一份吧!不過不知道能否支持繁體
      

  11.   

    回复人: hqhhh(枫叶) ( ) 信誉:100  2005-09-03 17:21:00  得分: 0  
     
     
       楼上的方法不全,有很多汉字都查询不出来!to:jackie168(三箭齐发),不好意思,我以前也用过这种方法,但很多字都不能生成,后来在网上又找了一个方法,代码很长,贴不上来!  
     
    >>>没啥不好意思的。另:方便的话,也发一份给我,3Q  mail:[email protected]
      

  12.   

    >>唉。我的朋友有个很棒的DLL,源码公开,不过用C写的。你们用不到……C写的不也能转成D吗?不过说实话,我看见C++或者C的代码就会晕,可读性不太好
      

  13.   

    能給我一份嘛? 郵箱 [email protected]
      

  14.   

    hqhhh(枫叶)大好人啊,发我一份[email protected]
      

  15.   

    mfwzhou(無邊的風):
    繁体也是可以的,只是多音字不行:)实测例子:
    输入: 中华人民共和国法律的执行机关 + 中華人民共和國法律的執行機關
    输出:zhong hua ren min gong he guo fa lv de zhi hang ji guan  + zhong kua ren min gong he guo fa lv de zhi hang ji wan 
      

  16.   

    // 取汉字的拼音
    function GetHzPy(const AHzStr: string): string;
    const
      ChinaCode: array[0..25, 0..1] of Integer = ((1601, 1636), (1637, 1832), (1833, 2077),
        (2078, 2273), (2274, 2301), (2302, 2432), (2433, 2593), (2594, 2786), (9999, 0000),
        (2787, 3105), (3106, 3211), (3212, 3471), (3472, 3634), (3635, 3722), (3723, 3729),
        (3730, 3857), (3858, 4026), (4027, 4085), (4086, 4389), (4390, 4557), (9999, 0000),
        (9999, 0000), (4558, 4683), (4684, 4924), (4925, 5248), (5249, 5589));
    var
      i, j, HzOrd: Integer;
    begin
      Result:='';
      i := 1;
      while i <= Length(AHzStr) do
      begin
        if (AHzStr[i] >= #160) and (AHzStr[i + 1] >= #160) then
        begin
          HzOrd := (Ord(AHzStr[i]) - 160) * 100 + Ord(AHzStr[i + 1]) - 160;
          for j := 0 to 25 do
          begin
            if (HzOrd >= ChinaCode[j][0]) and (HzOrd <= ChinaCode[j][1]) then
            begin
              Result := Result + Char(Byte('A') + j);
              Break;
            end;
          end;
          Inc(i);
        end else Result := Result + AHzStr[i];
        Inc(i);
      end;
    end;
    是别人写的函数,我在网上找的.
      

  17.   

    能給我一份嘛? 郵箱 [email protected]
    能给我壹份吗? [email protected]