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CJJYCLYCJPCPZJZJMMYLCQLNQLJQJSXYJMLSZLJQLYCMMHCFMMFPQQMFYLQMCFFQMMMMHMZNFHHJGTTHHKHSLNCHHYQDXTMMQD"_
&"CYZYXYQMYQYLTDCYYYZAZZCYMZYDLZFFFMMYCQZWZZMABTBYZTDMNZZGGDFTYPCGQYTTSSFFWFDTZQSSYSTWXJHXYTSXXYLBYQHW"_
&"WKXHZXWZNNZZJZJJQJCCCHYYXBZXZCYZTLLCQXYNJYCYYCYNZZQYYYEWYCZDCJYCCHYJLBTZYYCQWMPWPYMLGKDLDLGKQQBGYCHJ"_
&"XY"
'如果不在汉字范围内,则直接返回内容
if ascw(char)<19968 and ascw(char)>40869 then
 GetPy4Utf = char
else
 '查找对应首字母
 GetPy4Utf = Mid(strCHSfirstPY,(ascw(char)-19967),1)
end if
end function
'//生成汉字串首字母串
function getpy(str)
for i=1 to len(str)
 getpy=getpy & GetPy4Utf(mid(str,i,1))
next
end function
%>

  原理很简单,找对应位置的字母就行了,而相对来说,ANSII编码的就简单多了,看代码

 '//获取汉字的首字母
function getpychar(char)
dim tmpp:tmpp=65536+asc(char)
 if(tmpp>=45217 and tmpp<=45252) then
 getpychar= "A"
elseif(tmpp>=45253 and tmpp<=45760) then
 getpychar= "B"
elseif(tmpp>=45761 and tmpp<=46317) then
 getpychar= "C"
elseif(tmpp>=46318 and tmpp<=46825) then
 getpychar= "D"
elseif(tmpp>=46826 and tmpp<=47009) then
 getpychar= "E"
elseif(tmpp>=47010 and tmpp<=47296) then
 getpychar= "F"
elseif(tmpp>=47297 and tmpp<=47613) then
 getpychar= "G"
elseif(tmpp>=47614 and tmpp<=48118) then
 getpychar= "H"
elseif(tmpp>=48119 and tmpp<=49061) then
 getpychar= "J"
elseif(tmpp>=49062 and tmpp<=49323) then
 getpychar= "K"
elseif(tmpp>=49324 and tmpp<=49895) then
 getpychar= "L"
elseif(tmpp>=49896 and tmpp<=50370) then
 getpychar= "M"
elseif(tmpp>=50371 and tmpp<=50613) then
 getpychar= "N"
elseif(tmpp>=50614 and tmpp<=50621) then
 getpychar= "O"
elseif(tmpp>=50622 and tmpp<=50905) then
 getpychar= "P"
elseif(tmpp>=50906 and tmpp<=51386) then
 getpychar= "Q"
elseif(tmpp>=51387 and tmpp<=51445) then
 getpychar= "R"
elseif(tmpp>=51446 and tmpp<=52217) then
 getpychar= "S"
elseif(tmpp>=52218 and tmpp<=52697) then
 getpychar= "T"
elseif(tmpp>=52698 and tmpp<=52979) then
 getpychar= "W"
elseif(tmpp>=52980 and tmpp<=53640) then
 getpychar= "X"
elseif(tmpp>=53689 and tmpp<=54480) then
 getpychar= "Y"
elseif(tmpp>=54481 and tmpp<=62289) then
 getpychar= "Z"
else '如果不是中文,则不处理
 getpychar=char
end if
end function
'//生成汉字串首字母串
function getpy(str)
for i=1 to len(str)
 getpy=getpy & getpychar(mid(str,i,1))
next
end function

 我的Unicode版本的是从别人的C#版的转过来的,想看原文的话,点这里

本文关键:取得汉字字符串的首字母串
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top