CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

如何获得汉字汉语拼音的第一个字母

楼主EastLin(东林)2005-01-20 22:37:26 在 Web 开发 / ASP 提问

数据库存了大量的人名,希望能按照姓名汉语拼音第一个字母排序,并且能把姓名第一个字的汉语拼音的第一个字母显示出来,用ASP能取得汉字拼音的第一个字母吗? 问题点数:20、回复次数:14Top

1 楼SunshineRide(网魂)回复于 2005-01-20 22:41:55 得分 1

两个函数完成。  
  第一个函数,把汉字转化为拼音.  
  第二函数,把拼音的第一个字母取出来。  
  第一个函数需要自己写。  
  第二函数,VBS自带.Top

2 楼Hozaka(空虚的狼)回复于 2005-01-21 00:42:04 得分 0

中文字太多了Top

3 楼scoutlin(挖摸追挖摸追挖摸追..)回复于 2005-01-21 01:06:52 得分 1

其实不多  
  楼主要的只是中国的"姓"而已Top

4 楼qfacy(两袖清风)回复于 2005-01-21 08:34:28 得分 9

<%  
          response.write   "<link   href=style.css   rel=stylesheet>"  
              if   request.form("content")=""   then  
              response.write   "<center><form   method=post   action=><input   name=content   type=text>__<input   type=submit></form>"  
              else  
              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<=53640)   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  
              content=request.form("content")  
              response.write   "<center>"&getpy(content)&chr(10)  
              response.write   "<br><br><br><a   href=#   onclick=javascript:history.go(-1)>返回</a>"  
              end   if  
              %>Top

5 楼baikaishui_0825(baikaishui)回复于 2005-01-21 08:45:06 得分 7

汉字转拼音  
  http://blog.csdn.net/baikaishui_0825/archive/2005/01/19/259179.aspxTop

6 楼huhanshan013(飞兵团将军)回复于 2005-01-21 08:46:48 得分 0

关注Top

7 楼syre(神仙)回复于 2005-01-21 09:46:19 得分 0

google  
  Top

8 楼klions()回复于 2005-01-21 09:52:03 得分 0

好像不错也Top

9 楼superdullwolf(超级大笨狼,每天要自强,MVP)回复于 2005-01-21 09:54:06 得分 2

/*-1.-获得汉字字符串的首字母  
   
        根据大力的贴子改成.将大力的两个函数合并成了一个函数.  
        可以应用于助记码的查询  
  --*/  
  if   exists   (select   *   from   dbo.sysobjects   where   id   =   object_id(N'[dbo].[fGetPy]')   and   xtype   in   (N'FN',   N'IF',   N'TF'))  
  drop   function   [dbo].[fGetPy]  
  GO  
   
  --创建取拼音函数  
  create   function   fGetPy(@Str   varchar(500)='')  
  returns   varchar(500)  
  as  
  begin  
    declare   @strlen   int,@return   varchar(500),@ii   int  
    declare   @n   int,@c   char(1),@chn   nchar(1)  
   
    select   @strlen=len(@str),@return='',@ii=0  
    set   @ii=0  
    while   @ii<@strlen  
    begin  
      select   @ii=@ii+1,@n=63,@chn=substring(@str,@ii,1)  
      if   @chn>'z'  
      select   @n   =   @n   +1  
            ,@c   =   case   chn   when   @chn   then   char(@n)   else   @c   end  
        from(  
          select   top   27   *   from   (  
            select   chn   =   '吖'  
            union   all   select   '八'  
            union   all   select   '嚓'  
            union   all   select   '咑'  
            union   all   select   '妸'  
            union   all   select   '发'  
            union   all   select   '旮'  
            union   all   select   '铪'  
            union   all   select   '丌'     --because   have   no   'i'  
            union   all   select   '丌'  
            union   all   select   '咔'  
            union   all   select   '垃'  
            union   all   select   '嘸'  
            union   all   select   '拏'  
            union   all   select   '噢'  
            union   all   select   '妑'  
            union   all   select   '七'  
            union   all   select   '呥'  
            union   all   select   '仨'  
            union   all   select   '他'  
            union   all   select   '屲'     --no   'u'  
            union   all   select   '屲'     --no   'v'  
            union   all   select   '屲'  
            union   all   select   '夕'  
            union   all   select   '丫'  
            union   all   select   '帀'  
            union   all   select   @chn)   as   a  
          order   by   chn   COLLATE   Chinese_PRC_CI_AS    
        )   as   b  
      else   set   @c='a'  
      set   @return=@return+@c  
    end  
    return(@return)  
  end  
   
  go  
  --测试  
  select   dbo.fgetpy('青藏高原')   as   东莞市,dbo.fgetpy('ab中c国人')   as   中国人  
   
  --删除拼音函数  
  drop   function   fgetpy  
  Top

10 楼SunshineRide(网魂)回复于 2005-01-21 09:57:29 得分 0

刚刚看了一下.很抱歉,我给了你错误的答案。  
  你是存放在数据库中的人名.那么,你排序的时候,根本不需要进行转换了。直接ORDER   BY   username就行了。  
   
  生序降序随便你。  
   
  Top

11 楼superdullwolf(超级大笨狼,每天要自强,MVP)回复于 2005-01-21 09:57:36 得分 0

--测试  
  select   dbo.fgetpy('超级狼')   as   超级狼,dbo.fgetpy('中国人')   as   中国人  
  Top

12 楼SunshineRide(网魂)回复于 2005-01-21 10:04:21 得分 0

哈哈。.大狼,你理解错了啊。  
  他是要按照人名进行输出排序.  
  这根本就不需要转化汉字.直接就可以order排序了。Top

13 楼surferc((大妹子,缘分啊!))回复于 2005-01-21 16:28:07 得分 0

楼上说的对。  
  直接   select   ......   order   by   姓名字段  
  这里的排序规则已经自动按中文首字拼音第一个字母的顺序排列。Top

14 楼surferc((大妹子,缘分啊!))回复于 2005-01-21 16:30:35 得分 0

忘了说了首字拼音的第一字母应该做个对照表来显示(好在中国的姓氏不是很多复姓可以用第一个)。也可能有其它的方法Top

相关问题

  • 取汉语拼音首字母问题
  • 如何取得一个汉字的汉语拼音?
  • 如何的到汉字的汉语拼音
  • 在C/C++中如何实现:输入汉字,输出汉语拼音码????
  • 如何得到汉字与汉语拼音对应的数据库?
  • 在pb10中如何实现获得汉字拼音首字母?
  • 汉语拼音输入法程序?
  • 汉语拼音的奇怪问题.
  • 谁用过sapi.dll(SpeechLib),怎么用它获得汉字的拼音首字母啊?
  • 请高手!!!如何获得一组汉字的拼音首字母串???

关键词

  • 字母
  • 函数
  • 汉字
  • 排序
  • 中国
  • fgetpy
  • 汉语拼音
  • chn
  • 拼音
  • union all select

得分解答快速导航

  • 帖主:EastLin
  • SunshineRide
  • scoutlin
  • qfacy
  • baikaishui_0825
  • superdullwolf

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo