加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程 > 正文

一个效率很高的汉字转拼音首字母的函数

发布时间:2020-12-25 01:58:52 所属栏目:编程 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 create function [dbo].[fn_getpy](@str nvarchar(4000)) returns nvarchar(4000) as begin declare @str_len int,@result nvarchar(4000),@crs nvarc

以下代码由PHP站长网 52php.cn收集自互联网

现在PHP站长网小编把它分享给大家,仅供参考

create   function   [dbo].[fn_getpy]
(@str   nvarchar(4000)) 
returns   nvarchar(4000) 
as 
begin 
declare   @str_len   int,@result   nvarchar(4000),@crs nvarchar(1)
set @str_len=len(@str)
set @result= ' ' 
    while   @str_len> 0 
    begin 
set  @crs=substring(@str,@str_len,1)
 
   select  @[email?protected]_len-1,@result=
     case  
     when @crs>='帀' then 'Z'
     when @crs>='丫' then 'Y'
     when @crs>='夕' then 'X'
     when @crs>='屲' then 'W'
     when @crs>='他' then 'T'
     when @crs>='仨' then 'S'
     when @crs>='呥' then 'R'
     when @crs>='七' then 'Q'
     when @crs>='妑' then 'P'
     when @crs>='噢' then 'O'
     when @crs>='拏' then 'N'
     when @crs>='嘸' then 'M'
     when @crs>='垃' then 'L'
     when @crs>='咔' then 'K'
     when @crs>='丌' then 'J'
     when @crs>='铪' then 'H'
     when @crs>='旮' then 'G'
     when @crs>='发' then 'F'
     when @crs>='妸' then 'E'
     when @crs>='咑' then 'D'
     when @crs>='嚓' then 'C'
     when @crs>='八' then 'B'
     when @crs>='吖' then 'A'
     else  @crs  [email?protected]
    end 
    return(@result) 
end


以上内容由PHP站长网【52php.cn】收集整理供大家参考研究

如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读