如何提取中文字串的拼音首字母
转贴 // 获取指定汉字的拼音索引字母 function GetPYIndexChar( 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'; $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'; else result := char(0); end; end; //得到中文助记码 function ChineseZjmChar(const s: String): string; var SW: WideString; C,D: String; i : integer; begin try SW := S; D:=''; for i :=1 to Length(SW) do begin C := SW[i]; if Length(C) > 1 then begin D:=D+GetPYIndexChar(C); end; end; result := D; except Result := ''; end; end; 不过只能得到常用字。
采纳哦。
如何提取中文字串的拼音首字母
转贴
// 获取指定汉字的拼音索引字母
function GetPYIndexChar( 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';
$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';
else
result := char(0);
end;
end;
//得到中文助记码
function ChineseZjmChar(const s: String): string;
var
SW: WideString;
C,D: String;
i : integer;
begin
try
SW := S;
D:='';
for i :=1 to Length(SW) do
begin
C := SW[i];
if Length(C) > 1 then begin
D:=D+GetPYIndexChar(C);
end;
end;
result := D;
except
Result := '';
end;
end;
不过只能得到常用字。
怎样将Word文档中的人名按照拼音首字母排序
现有替换将序号所在段落后的回车符替换成一个特殊词组比如中文的中括号【】
方法:ctrl+h调出替换对话框
查找内容输入:^13([!0-9])
替换为输入:【】\1
高级或更多选择“使用通配符”,点击全部替换
然后将首字母前插入tab键
方法:ctrl+h调出替换对话框
查找内容输入:([0-9]{1,4}.)([A-z])
替换为输入:\1\t\2
高级或更多选择“使用通配符”,点击全部替换
然后复制所有内容粘贴到Excel中,用Excel的排序功能将第二列排序,然后复制全部内容粘贴回word,仅保留文字,然后将tab键替换掉,【】替换回回车符。
SQL语句提取出中文的拼音首字母
正好最近收藏了一个 你可以看下思路
--将中文字符串转化成文字首拼音的组合
create function fun_getPY(@str nvarchar(4000))
returns nvarchar(4000)
as
begin
declare @word nchar(1),@PY nvarchar(4000)
set @PY=''
while len(@str)>0
begin
set @word=left(@str,1)
--如果非汉字字符,返回原字符
set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901
then (select top 1 PY from (
select 'A' as PY,N'骜' as word
union all select 'B',N'簿'
union all select 'C',N'错'
union all select 'D',N'鵽'
union all select 'E',N'樲'
union all select 'F',N'鳆'
union all select 'G',N'腂'
union all select 'H',N'夻'
union all select 'J',N'攈'
union all select 'K',N'穒'
union all select 'L',N'鱳'
union all select 'M',N'旀'
union all select 'N',N'桛'
union all select 'O',N'沤'
union all select 'P',N'曝'
union all select 'Q',N'囕'
union all select 'R',N'鶸'
union all select 'S',N'蜶'
union all select 'T',N'箨'
union all select 'W',N'鹜'
union all select 'X',N'鑂'
union all select 'Y',N'韵'
union all select 'Z',N'咗'
) T
where word>=@word collate Chinese_PRC_CS_AS_KS_WS
order by PY ASC) else @word end)
set @str=right(@str,len(@str)-1)
end
return @PY
end
--函数调用实例:
select dbo.fun_getPY('中华人民共和国AAA01')
/*
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ZHRMGHGAAA01
(1 行受影响)
*/
Excel如何用函数提取汉字的大写首字母
1,复制姓名列,粘贴到word里
2,在word里,点击右下角粘贴智能标记,选择“仅保留文本”
3,选中word里的姓名文字(一般一次能一次性添加13组拼音,如果要添加拼音的汉字比较多,多选择几次多设置几次),开始-字体-拼音指南,拼音指南里,字号调大一些,确定
4,复制添加了拼音的汉字,粘贴到excel里某空列
5,用函数PHONETIC取得单元格里的拼音信息字符串,C2=PHONETIC(B2)
转载请注明出处51数据库 » word提取拼音首字母