create function [dbo].[f_getpy](@str nvarchar(4000))
returns nvarchar(4000)
asbegin
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)
endreturn @py
end
SQL從中文中獲取拼音首字母
全部扔進去執行,不用修改 create function dbo.fnpbgetpyfirstletter str nvarchar 4000 select dbo.fnpbgetpyfirstletter 中國香港 returns nvarchar 4000 with encryption asb...
js 獲取中文的拼音首字母
es6 模組化封裝 use strict module.exports 處理arrresult,返回所有可能的拼音首字母串陣列 return this mkrslt arrresult checkch ch 檢查是否是多音字,是按多音字處理,不是就直接在strchinesefirstpy字串中找對應...
js 根據中文獲取拼音首字母
js部分 var pinyin param str 判斷中英文 returns 中文返回true,其他返回false function ischinese str param str 獲取拼音的字串 param split 拼音分隔符 param uppercase 是否轉為大寫 returns 結...