见到有的进销存系统有这样的功能,输入“KKKL”后商品就能弹出“可口可乐”,却不需要在输入这个商品时人工输入对应的拼音,这是怎么实现的?

解决方案 »

  1.   

    在数据库输入中,怎样使"中文名称"输入翻译成"简码"存入另一字段?以便以后查询使用?如:"工资处"译成"GZC" //这个函数拿去用(我刚写好,已测试通过)function GetHzPy(const AHzStr: string): string;constChinaCode: 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));vari, j, HzOrd: integer;Hz: string[2];begini := 1;while i <= Length(AHzStr) dobeginif (AHzStr[i] >= #160) and (AHzStr[i + 1] >= #160) thenbeginHzOrd := (Ord(AHzStr[i]) - 160) * 100 + Ord(AHzStr[i + 1]) - 160;for j := 0 to 25 dobeginif (HzOrd >= ChinaCode[j][0]) and (HzOrd <= ChinaCode[j][1]) thenbeginResult := Result + char(byte('A') + j);break;end;end;Inc(i);end else Result := Result + AHzStr[i];Inc(i);end;end;///////////////////////////////////////这个函数用户识别单独汉字的简码 字符串的简码函数请自行制作function GetPYIndexChar(hzchar:string):char;begincase WORD(hzchar[1]) shl 8 + WORD(hzchar[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;end;
      

  2.   

    :sfwany
    可以问问您的函数的原理是什么吗?