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

ASP 2010. 10. 5. 16:31 Posted by Dayis
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

'ASP' 카테고리의 다른 글

ASP 파라메터 컨트롤 함수  (0) 2012.01.09
jquery 파일 업로드  (0) 2010.12.10
구글맵  (0) 2010.12.09
구글맵 API Key 생성 URL  (0) 2010.12.01
ASP 배열을 자바스크립트 배열로 변경  (0) 2010.12.01