f_get_pym.srf 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. $PBExportHeader$f_get_pym.srf
  2. $PBExportComments$汉字拼音的函数
  3. global type f_get_pym from function_object
  4. end type
  5. forward prototypes
  6. global function string f_get_pym (string as_inputstring)
  7. end prototypes
  8. global function string f_get_pym (string as_inputstring);//返回汉字拼音的函数,支持混合字符传(可以包含非汉字)
  9. //利用PB6能够对汉字进行比较的功能,可以生成所有的汉字拼音码......
  10. //在PB6.5版本下通过
  11. //SunGxf Soft 顾伟章
  12. //注:核心思路来源与陶清PB论坛上,非常感谢
  13. long i
  14. string ls_ch,ls_returnStr
  15. For i=1 to Len(as_InputString) //依次处理as_InputString中每个字符
  16. ls_ch=Mid(as_InputString , i , 1)
  17. If Asc(ls_ch)<128 then // 非汉字
  18. ls_returnStr = ls_returnStr+ls_ch // 不变
  19. Else // 是汉字
  20. ls_ch = Mid(as_InputString , i , 1) // 取出此汉字
  21. //处理汉字
  22. CHOOSE CASE ls_ch
  23. CASE is >= '匝'
  24. ls_returnStr += "Z"
  25. CASE is >= '丫'
  26. ls_returnStr += "Y"
  27. CASE is >= '夕'
  28. ls_returnStr += "X"
  29. CASE is >= '哇'
  30. ls_returnStr += "W"
  31. CASE is >= '他'
  32. ls_returnStr += "T"
  33. CASE is >= '撒'
  34. ls_returnStr += "S"
  35. CASE is >= '然'
  36. ls_returnStr += "R"
  37. CASE is >= '七'
  38. ls_returnStr += "Q"
  39. CASE is >= '趴'
  40. ls_returnStr += "P"
  41. CASE is >= '哦'
  42. ls_returnStr += "O"
  43. CASE is >= '拿'
  44. ls_returnStr += "N"
  45. CASE is >= '妈'
  46. ls_returnStr += "M"
  47. CASE is >= '廓'
  48. ls_returnStr += "L"
  49. CASE is >= '咖'
  50. ls_returnStr += "K"
  51. CASE is >= '讥'
  52. ls_returnStr += "J"
  53. CASE is >= '哈'
  54. ls_returnStr += "H"
  55. CASE is >= '嘎'
  56. ls_returnStr += "G"
  57. CASE is >= '发'
  58. ls_returnStr += "F"
  59. CASE is >= '讹'
  60. ls_returnStr += "E"
  61. CASE is >= '搭'
  62. ls_returnStr += "D"
  63. CASE is >= '擦'
  64. ls_returnStr += "C"
  65. CASE is >= '八'
  66. ls_returnStr += "B"
  67. CASE is >= '阿'
  68. ls_returnStr += "A"
  69. END CHOOSE
  70. // i = i+1 // 指向下一个汉字
  71. End if
  72. Next // 处理完毕
  73. RETURN ls_returnStr
  74. end function