计算机二级:delphi中获取汉字的拼音首字母
来源:优易学  2011-6-7 12:57:11   【优易学:中国教育考试门户网】   资料下载   IT书店

 

  case Byte(Value[1]) of
  161..194: Result := \'M\';
  195..254: Result := \'N\';
  end; {case}
  197:
  case Byte(Value[1]) of
  161..181: Result := \'N\';
  182..189: Result := \'O\';
  190..254: Result := \'P\';
  end; {case}
  198:
  case Byte(Value[1]) of
  161..217: Result := \'P\';
  218..254: Result := \'Q\';
  end; {case}
  199:
  Result := \'Q\';
  200:
  case Byte(Value[1]) of
  161..186: Result := \'Q\';
  187..245: Result := \'R\';
  246..254: Result := \'S\';
  end; {case}
  201..202:
  Result := \'S\';
  203:
  case Byte(Value[1]) of
  161..249: Result := \'S\';
  250..254: Result := \'T\';
  end; {case}
  204:
  Result := \'T\';
  205:
  case Byte(Value[1]) of
  161..217: Result := \'T\';
  218..254: Result := \'W\';
  end; {case}
  206:
  case Byte(Value[1]) of
  161..243: Result := \'W\';
  244..254: Result := \'X\';
  end; {case}
  207..208:
  Result := \'X\';
  209:
  case Byte(Value[1]) of
  161..184: Result := \'X\';
  185..254: Result := \'Y\';
  end; {case}
  210..211:
  Result := \'Y\';
  212:
  case Byte(Value[1]) of
  161..208: Result := \'Y\';
  209..254: Result := \'Z\';
  end; {case}
  213..215:
  Result := \'Z\';
  216..247:
  Result := py[Byte(Value[0])][Byte(Value[1]) - 160];
  end; {case}
  end;
  function ChnToPY(Value: string): string;
  var
  I, L: Integer;
  C: array[0..1] of char;
  R: Char;
  begin
  Result := \'\';
  L := Length(Value);
  I := 1;
  while I <= (L - 1) do
  begin
  if Value[I] < #160 then
  begin
  Result := Result + Value[I];
  Inc(I);
  end
  else
  begin
  C[0] := Value[I];
  C[1] := Value[I + 1];
  R := ChnPY(C);
  if r <> #0 then
  Result := Result + R;
  Inc(I, 2);
  end;
  end;
  if I = L then
  Result := Result + Value[L];
  end;
  2、函数引用
  edit2.Text:=ChnToPY(trim(edit1.Text));

上一页  [1] [2] [3] 

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训