Returns the phonetic first letter of a string

Source: Internet
Author: User
Pinyin
//////////////////////////////////////////////////////////////
file://function Name: Gf_getfirstletter (String)
file://function: Returns the phonetic first letter of the string, supports mixed strings (can contain non-Chinese characters)
file://parameter: as_inputstring
file://return Value: String
file://created Datong Zhang Heping dtzhp@yeah.net
//////////////////////////////////////////////////////////////
Long I
String Ls_ch,ls_returnstr
For I=1 to Len (as_inputstring) file://process each character in the as_inputstring sequence
Ls_ch=mid (As_inputstring, I, 1)
If ls_ch < "ah" then//non-kanji
LS_RETURNSTR = ls_returnstr+ls_ch//unchanged
Elseif ls_ch >= "Ah" and ls_ch <= "seat" then file://processing first-class Chinese characters
CHOOSE Case Ls_ch
Case is >= ' turn '
LS_RETURNSTR = "Z"
Case is >= ' pressure '
Ls_returnstr + = "Y"
Case is >= ' shake '
LS_RETURNSTR = "X"
Case is >= ' dig '
Ls_returnstr = "W"
Case is >= ' collapse '
Ls_returnstr = "T"
Case is >= ' Zacchaeus '
Ls_returnstr = "S"
Case is >= ' yes '
Ls_returnstr + = "R"
Case is >= ' period '
LS_RETURNSTR = "Q"
Case is >= ' PA '
Ls_returnstr + = "P"
Case is >= ' Oh '
Ls_returnstr = "O"
Case is >= ' take '
Ls_returnstr + = "n"
Case is >= ' ma '
Ls_returnstr = "M"
Case is >= ' garbage '
Ls_returnstr = "L"
case is >= ' ka '
Ls_returnstr = "K"
Case is >= ' hit '
Ls_returnstr = "J"
Case is >= ' ha '
LS_RETURNSTR = "H"
Case is >= ' karma '
Ls_returnstr + + "G"
Case is >= ' hair '
Ls_returnstr = "F"
Case is >= ' moth '
Ls_returnstr + = "E"
Case is >= ' lap '
LS_RETURNSTR = "D"
Case is >= ' wipe '
Ls_returnstr = "C"
Case is >= ' BA '
Ls_returnstr = "B"
Case is >= ' ah '
Ls_returnstr = "a"
End CHOOSE
ElseIf ls_ch > "seat" then file://processing first-class Chinese characters
Select Py into:ls_py from piyin where Hanzi =: ls_ch;
End If
i = i+1 file://PB8 do not use this sentence, and PB65 to be used, point to the next Chinese character

Next
Return LS_RETURNSTR




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.