Powerbuilder-PB用于全角,半角互相转换的函数
PB2021全角转半角测试通过。/*
* Script Name: Script - Full2Half(string in_str,integer iflag)
* Description: 用于全角,半角互相转换的函数
* Arguments: string strInfo //需要转换的字符串
int iFlag // 1-全角-》半角 2-半角》全角
* Returns: string
* Author: Date: 2009-02-26 09:08:58
*/
String ls_rtn
Char c[]
long ll_length,ll_i
If IsNull(in_str) Or in_str = "" Then Return ""
ll_length = len(in_str)
if iflag=1 then //1-全角-》半角
For ll_i = 1 To ll_length
c = char(mid(in_str, ll_i, 1))
If (Asc(c) = 12288)Then
c = Char(32)
Continue
End If
If (Asc(c) > 65280and Asc(c) < 65375) Then
c = Char(Asc(c) - 65248)
End If
Next
elseif iflag=2 then//2-半角》全角
For ll_i = 1 To ll_length
c = char(mid(in_str, ll_i, 1))
If (Asc(c) = 32)Then
c = Char(12288)
Continue
End If
If (Asc (c) < 127) Then
c = Char(Asc(c) + 65248)
End If
Next
end if
ls_rtn = c
Return ls_rtn
页:
[1]