一个取汉字的首字母的 asp代码

本文介绍了一个使用VBScript实现的将汉字转换为对应拼音首字母的简单示例。该示例通过定义一系列Unicode范围来匹配不同的拼音首字母,并提供了一个函数用于处理输入字符串中的每个字符。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. <%
  2. function getpychar(char
  3. dim tmp 
  4. tmp=65536+asc(char
  5. if(tmp>=45217 and tmp<=45252) then 
  6. getpychar= "A" 
  7. elseif(tmp>=45253 and tmp<=45760) then 
  8. getpychar= "B" 
  9. elseif(tmp>=45761 and tmp<=46317) then 
  10. getpychar= "C" 
  11. elseif(tmp>=46318 and tmp<=46825) then 
  12. getpychar= "D" 
  13. elseif(tmp>=46826 and tmp<=47009) then 
  14. getpychar= "E" 
  15. elseif(tmp>=47010 and tmp<=47296) then 
  16. getpychar= "F" 
  17. elseif(tmp>=47297 and tmp<=47613) then 
  18. getpychar= "G" 
  19. elseif(tmp>=47614 and tmp<=48118) then 
  20. getpychar= "H" 
  21. elseif(tmp>=48119 and tmp<=49061) then 
  22. getpychar= "J" 
  23. elseif(tmp>=49062 and tmp<=49323) then 
  24. getpychar= "K" 
  25. elseif(tmp>=49324 and tmp<=49895) then 
  26. getpychar= "L" 
  27. elseif(tmp>=49896 and tmp<=50370) then 
  28. getpychar= "M" 
  29. elseif(tmp>=50371 and tmp<=50613) then 
  30. getpychar= "N" 
  31. elseif(tmp>=50614 and tmp<=50621) then 
  32. getpychar= "O" 
  33. elseif(tmp>=50622 and tmp<=50905) then 
  34. getpychar= "P" 
  35. elseif(tmp>=50906 and tmp<=51386) then 
  36. getpychar= "Q" 
  37. elseif(tmp>=51387 and tmp<=51445) then 
  38. getpychar= "R" 
  39. elseif(tmp>=51446 and tmp<=52217) then 
  40. getpychar= "S" 
  41. elseif(tmp>=52218 and tmp<=52697) then 
  42. getpychar= "T" 
  43. elseif(tmp>=52698 and tmp<=52979) then 
  44. getpychar= "W" 
  45. elseif(tmp>=52980 and tmp<=53688) then 
  46. getpychar= "X" 
  47. elseif(tmp>=53689 and tmp<=54480) then 
  48. getpychar= "Y" 
  49. elseif(tmp>=54481 and tmp<=62289) then 
  50. getpychar= "Z" 
  51. else '如果不是中文,则不处理 
  52. getpychar=char 
  53. end if 
  54. end function 
  55. function getpy(str) 
  56. dim ret 
  57. for i=1 to len(str)
  58. ret=ret&getpychar(mid(str,i,1))
  59. next
  60. getpy=ret
  61. end function
  62. '这是使用的例子
  63. response.write getpy("我需要要测试一下")
  64. %>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值