/*
****************************
* Halfwidth <=> fullwidth *
* [NB Alliance] *
* Writer yuping *
****************************
* Parameter description:
* STR: string to be converted
* Flag: flag. The flag is converted to full at half past zero. If the flag is not 0, it is switched to half.
* Return value type: String
****************************
*/
Function dbc2sbc (STR, flag ){
VaR I;
VaR result = '';
If (Str. Length <= 0) {alert ('string parameter error'); Return false ;}
For (I = 0; I <Str. length; I ++)
{Str1 = Str. charcodeat (I );
If (str1 <125 &&! Flag)
Result + = string. fromcharcode (Str. charcodeat (I) + 65248 );
Else
Result + = string. fromcharcode (Str. charcodeat (I)-65248 );
}
Return result;
}
// Example:
Alert (dbc2sbc ("aaabc", 0 ));
Document. Write (dbc2sbc ("abcdefg", 0 )) '****************************
'* Halfwidth <=> fullwidth *
'* [NB Alliance] *
'* Writer yuping *
'****************************
'* Parameter description:
'* STR: string to be converted
'* Flag: flag. It is converted to full at half past zero. If it is not 0, it is switched to half.
'* Return value type: String
'****************************
Function dbc2sbc (STR, flag)
Dim I
If Len (STR) <= 0 then
Msgbox 'string parameter error'
Exit Function
End if
For I = 1 to Len (STR)
Str1 = ASC (mid (STR, I, 1 ))
If str1> 0 and str1 <= 125 and not flag then
Dbc2sbc = dbc2sbc & CHR (ASC (mid (STR, I, 1)-23680)
Else
Dbc2sbc = dbc2sbc & CHR (ASC (mid (STR, I, 1) + 23680)
End if
Next
End Function