'==================================================
' 원격지 파일을 읽어들인다.
'   호출 방법    :  getSiteSourceGet( siteURL, params )
'==================================================
Function getSiteSourceGet( siteURL, params )
 Set httpObj = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
 
 if Request.ServerVariables("HTTPS") = "on" then
  if instr(1,siteURL,"https://") < 1 then
   siteURL = "https://" & Request.ServerVariables("HTTP_HOST") & siteURL
  end if
 else
  if instr(1,siteURL,"http://") < 1 then
   siteURL = "http://" & Request.ServerVariables("HTTP_HOST") & siteURL
  end if
 End If 

 if len(params) > 0 then
  httpObj.open "GET", siteURL & "?" & params, False
 else
  httpObj.open "GET", siteURL, False
 end if
 
 httpObj.Send()
 httpObj.WaitForResponse
 If httpObj.Status = "200" Then
  getSiteSourceGet = httpObj.ResponseText
 Else
  getSiteSourceGet = null
 End If
End Function

top


'==================================================
'   한글과 영문을 구분해서 문자열 잘라서 Return
'   호출 방법    :  getCutString(문자열, 원하는 글자수)
' 입력 파라메터: strData(문자열,int글자)
'==================================================
Function getCutString(strString, intCutLen)
    Dim intLen '// 문자열 길이
    Dim intByte '// byte 수
    Dim strCutString
    Dim strRes
    Dim strChar
    Dim intX
    intLen = 0
    intByte = 0
    strRes = ""
    if IsNULL(strString) then
     intLen = 0
    else
     intLen = Len(trim(strString))
    end if
      

    For intX = 1 to intLen
        strChar = ""
        strCutString = Mid(strString, intX, 1)        '//    일단 1만큼 잘라서 strCutString에 저장한다.
        strChar = Asc(strCutString)        '//    아스키 코드값 읽어오기
        strChar = Left(strChar, 1)
        If strChar = "-" Then            '//    "-"이면 2바이트 문자임
            intByte = intByte + 2
        Else
            intByte = intByte + 1
        End If
        If intCutLen < intByte Then
            '// 현재 문자열 byte 수가 지정한 byte 수보다 크면 For 문을 빠져나간다.
            strRes = strRes & "..."
            Exit For
        Else
            '// 현재 문자열 byte 수가 지정한 byte 수보다 작으면 strRes 에 잘라낸 문자열을 추가한다.
            strRes = strRes & strCutString
        End If
    Next
    getCutString = strRes
End Function

'개발팁( ASP )' 카테고리의 다른 글

임시비밀번호 만들기  (0) 2013.07.12
원격지 파일을 읽기  (0) 2013.07.09
한글과 영문을 구분해서 문자열의 길이를 Return  (0) 2013.07.02
top


'==================================================
'   한글과 영문을 구분해서 문자열의 길이를 Return
'   호출 방법    :  getLength(문자열)
' 입력 파라메터: strData(문자열)
'==================================================
Function getLength(strData)
Dim nLen ' 문자열 길이값
Dim i
 nLen = 0
 if Len(strData) > 0 then
  for i = 1 to Len(strData)
   if Asc(Mid(strData,i,1)) < 0 then
    nLen = nLen + 2
   else
    nLen = nLen + 1
   end if
  next
 end if
 getLength = nLen
End Function

'개발팁( ASP )' 카테고리의 다른 글

임시비밀번호 만들기  (0) 2013.07.12
원격지 파일을 읽기  (0) 2013.07.09
한글과 영문을 구분해서 문자열 잘라서 Return  (0) 2013.07.02
top