码迷,mamicode.com
首页 > Windows程序 > 详细

Delphi中取得汉字的首字母(十分巧妙)

时间:2017-02-01 10:47:48      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:phi   and   code   ica   汉字   www   [1]   lin   else   

function Tdm.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;
技术分享//    Hz: string[2];
技术分享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 25do
技术分享            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;

 

http://www.cnblogs.com/hssbsw/archive/2012/12/04/2801958.html

Delphi中取得汉字的首字母(十分巧妙)

标签:phi   and   code   ica   汉字   www   [1]   lin   else   

原文地址:http://www.cnblogs.com/findumars/p/6359770.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!