如只要輸入'組件':就可以得到ZJ
人民郵電;得到rmyd
各位高手有沒有什么辦法!
人民郵電;得到rmyd
各位高手有沒有什么辦法!
解决方案 »
- 怎么样把一个ADO记录集复制给另外一个ADO记录集???
- Access数据库可否用于编写网络版程序?
- 关于打卡的问题
- 用DELPHI编写WINDOWS系统程序,有必要看关于WINDOWS下编程的书么??
- DELPHI中怎样调用其他程序?
- 请问如何在delphi中懂得今天是星期几?(100分相送)
- 简单dda法,感觉比delphi的还好,哈哈,大家试试我的myline()函数
- 多语言开发,如何实现录入阿拉伯文
- 如果数据表的字段和SQL的关键字相同,怎么办。
- FastReport 2.2报表控件能打印出“计算字段”的内容吗?
- 用delphi,如何生成一个二进制直接访问形式的文件?
- shellexecute和winexec那个好,调用外部exe的时候不希望出现命令窗口
/////////////////////////////////////////////////////////////////////////////
// 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.
[email protected]
谢谢.
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;
楼上的方法不全,有很多汉字都查询不出来!to:jackie168(三箭齐发),不好意思,我以前也用过这种方法,但很多字都不能生成,后来在网上又找了一个方法,代码很长,贴不上来!
>>>没啥不好意思的。另:方便的话,也发一份给我,3Q mail:[email protected]
繁体也是可以的,只是多音字不行:)实测例子:
输入: 中华人民共和国法律的执行机关 + 中華人民共和國法律的執行機關
输出: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
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;
是别人写的函数,我在网上找的.
能给我壹份吗? [email protected]