取得汉字的拼音首字母

来源:互联网 发布:网络电影发行平台 编辑:程序博客网 时间:2024/04/26 06:24
function  GetChineseAsc(const crStr:String;crLength:Integer):String;
var i,HighPosition,LowPosition:Integer;
    AscValue,AscStr:String;
begin
  Result:='';
  i:=2; //1个汉字占用两个字节
  while i<=Length(crStr) do
  begin
    if Length(Trim(Result))=crLength then Break; //如果超过一定长度,则退出
    HighPosition:=Ord(crStr[i-1])-160;
    LowPosition:=Ord(crStr[i])-160;
    if (HighPosition<16) or (HighPosition>55) or (LowPosition<=0) or (LowPosition>94) then
    begin
      //if HighPosition>
      if crStr[i-1] in ['a'..'z','A'..'Z'] then
        Result:=Result+UpperCase(crStr[i-1]);
      i:=i+1;
      Continue;
    end;
    AscValue:=FormatFloat('00',HighPosition)+FormatFloat('00',LowPosition);
    AscStr:='';
    if (AscValue>='1601') and (AscValue<='1636') then
      AscStr:='A';
    if (AscValue>='1637') and (AscValue<='1832') then
      AscStr:='B';
    if (AscValue>='1833') and (AscValue<='2077') then
      AscStr:='C';
    if (AscValue>='2078') and (AscValue<='2273') then
      AscStr:='D';
    if (AscValue>='2274') and (AscValue<='2301') then
      AscStr:='E';
    if (AscValue>='2302') and (AscValue<='2432') then
      AscStr:='F';
    if (AscValue>='2433') and (AscValue<='2593') then
      AscStr:='G';
    if (AscValue>='2594') and (AscValue<='2786') then
      AscStr:='H';
    if (AscValue>='2787') and (AscValue<='3105') then
      AscStr:='J';
    if (AscValue>='3106') and (AscValue<='3211') then
      AscStr:='K';
    if (AscValue>='3212') and (AscValue<='3471') then
      AscStr:='L';
    if (AscValue>='3472') and (AscValue<='3634') then
      AscStr:='M';
    if (AscValue>='3635') and (AscValue<='3721') then
      AscStr:='N';
    if (AscValue>='3722') and (AscValue<='3729') then
      AscStr:='O';
    if (AscValue>='3730') and (AscValue<='3857') then
      AscStr:='P';
    if (AscValue>='3858') and (AscValue<='4026') then
      AscStr:='Q';
    if (AscValue>='4027') and (AscValue<='4085') then
      AscStr:='R';
    if (AscValue>='4086') and (AscValue<='4389') then
      AscStr:='S';
    if (AscValue>='4390') and (AscValue<='4557') then
      AscStr:='T';
    if (AscValue>='4558') and (AscValue<='4683') then
      AscStr:='W';
    if (AscValue>='4684') and (AscValue<='4924') then
      AscStr:='X';
    if (AscValue>='4925') and (AscValue<='5248') then
      AscStr:='Y';
    if (AscValue>='5249') and (AscValue<='5589') then
      AscStr:='Z';
    Result:=Result+AscStr;
    I:=I+2
  end;
end; 
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 摩旅 手机不防水怎么办 头盔镜片花了怎么办 踏板摩托车速度底怎么办 摩托车头盔小了怎么办 房东和租客纠纷怎么办 租客与房东纠纷怎么办 乙肝打了瘦脸针怎么办 去绣水搞到手上痛怎么办 脚破了皮很痛怎么办 脚被车撞了肿了怎么办 ps4光盘花了怎么办 耳后总是长孑子怎么办 孩孑高三总是玩手机怎么办 摩托车被收了怎么办 摩托车的手续都怎么办 摩托车罚单掉了怎么办 行人遇到黄灯该怎么办 长辈借钱不还怎么办 不绣刚电梯轿壁有凹槽怎么办 电梯下限位故障怎么办 卫生间夏天太热怎么办 07大檐帽变形了怎么办 税务局不批发票怎么办 进项发票太多了怎么办 发票报销联丢失怎么办 发票领用簿没有怎么办 发票购买本遗失怎么办 销售方遗失发票怎么办 增值税发票发票联丢失怎么办 苹果购买发票丢失怎么办 空白增值税发票发票丢失怎么办 网购发票 领购簿怎么办 购物发票丢了怎么办 饭店客人买单要少钱怎么办 发票备注栏写错怎么办 卖房子发票丢失怎么办 发票二维码蓝票怎么办 车祸伤者出院怎么办 微信付款失败怎么办 增值税电子发票没打税号怎么办 买假出租车发票怎么办