ASP

전각/반각 구분하여 문자열 계산

Dayis 2010. 10. 5. 16:31
Function chrbyte(str,strlen)
 Dim returnStr, charat, cutchk, wLen, j
 cutchk = 0

 for j=1 to len(str)
  charat=mid(str, j, 1)
  if asc(charat)>0 And asc(charat)<255 Then
   If asc(charat) = 1 Then
    wLen=wLen+2 
   Else
    wLen=wLen+1 
   End If
  Else
   wLen=wLen+2
  end If
  
  returnStr = returnStr & charat

  If wLen >strlen Then
   cutchk = 1
   Exit for
  End if
 Next
 
 If cutchk = 1 then
  chrbyte = returnStr & ".."
 Else
  chrbyte = returnStr
 End if
end Function