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程式直接取,有點麻煩.
<%
function getpychar(char)
tmp=65536+asc(char)
if(tmp>=45217 and tmp<=45252) then
getpychar= "a"
elseif(tmp>=45253 and tmp<=45760) then
getpychar= "b"
elseif(tmp>=45761 and tmp<=46317) then
getpychar= "c"
elseif(tmp>=46318 and tmp<=46825) then
getpychar= "d"
elseif(tmp>=46826 and tmp<=47009) then
getpychar= "e"
elseif(tmp>=47010 and tmp<=47296) then
getpychar= "f"
elseif(tmp>=47297 and tmp<=47613) then
getpychar= "g"
elseif(tmp>=47614 and tmp<=48118) then
getpychar= "h"
elseif(tmp>=48119 and tmp<=49061) then
getpychar= "j"
elseif(tmp>=49062 and tmp<=49323) then
getpychar= "k"
elseif(tmp>=49324 and tmp<=49895) then
getpychar= "l"
elseif(tmp>=49896 and tmp<=50370) then
getpychar= "m"
elseif(tmp>=50371 and tmp<=50613) then
getpychar= "n"
elseif(tmp>=50614 and tmp<=50621) then
getpychar= "o"
elseif(tmp>=50622 and tmp<=50905) then
getpychar= "p"
elseif(tmp>=50906 and tmp<=51386) then
getpychar= "q"
elseif(tmp>=51387 and tmp<=51445) then
getpychar= "r"
elseif(tmp>=51446 and tmp<=52217) then
getpychar= "s"
elseif(tmp>=52218 and tmp<=52697) then
getpychar= "t"
elseif(tmp>=52698 and tmp<=52979) then
getpychar= "w"
elseif(tmp>=52980 and tmp<=53688) then
getpychar= "x"
elseif(tmp>=53689 and tmp<=54480) then
getpychar= "y"
elseif(tmp>=54481 and tmp<=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
response.write getpy("測")
%>
取漢字拼音首字母的儲存過程
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...
取漢字拼音首字母的儲存過程
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...
取漢字拼音首字母的儲存過程
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...