close

全形與半形應該只會發生在數字及大小寫英文字上
依據此理論可使用一個比較簡單的理論來實作,如下
1.問題:
   希望將 123大12345寫6456AB字Cabc
   轉換成 123大12345寫6456AB字Cabc
2.程式參考如下
string ls_char
string ls_result
string ls_string = '123大12345寫6456AB字Cabc'
string ls_data1 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
string ls_data2 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
integer i , li_pos
for i = 1 to len(ls_string)
   ls_char = mid( ls_string , i , 1 )
   if asc(ls_char) > 127 then
     ls_result += mid( ls_string , i , 2 )
     i ++
   else
     if (asc( ls_char ) >= 48 and asc( ls_char ) <= 57) or (asc( ls_char ) >= 65 and asc( ls_char ) <= 90) or (asc( ls_char ) >= 97 and asc( ls_char ) <= 122) then
     li_pos = pos( ls_data2 , ls_char )
     if li_pos > 0 then
     ls_result += mid( ls_data1 , (li_pos * 2 - 1) , 2 )
     else
     ls_result += mid( ls_string , i , 1 )
     end if
     else
     ls_result += mid( ls_string , i , 1 )
     end if
   end if
next
messagebox( 'Result' , ls_result )


PowerBuilder 廣告 - egg


 PowerBuilder 廣告 - breakfirst

arrow
arrow
    全站熱搜

    PB 發表在 痞客邦 留言(0) 人氣()