有没有办法 从中文字符串生成拼音字母的字串? 好老师我会另开贴给分

lostmyway 2003-10-15 03:22:19
比如说原字串为"文件管理",以其每个汉字拼音的第一个字母生成字母字串"wjgl"

有什么好办法吗?
...全文
61 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lostmyway 2003-10-16
  • 打赏
  • 举报
回复
谢谢 请来帖子名为“谢“恩师”...” 来领取另外20分!
pankun 2003-10-15
  • 打赏
  • 举报
回复
从汉字来得到首字母的方法,你再扩展一下应就可以满足你的需求了.

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function getpy(hzchar:string):char;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

function TForm1.getpy(hzchar: string): char;
begin
case 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';
$B9C1..$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';
$D189..$D4D0 : result:='Y';
$D4D1..$D7F9 : result:='Z';
else
result:=char(0);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
begin
s:=getpy('新')+getpy('闻')+getpy('频')+getpy('道');
showmessage(s);
end;

end.

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧