VBScript는 내부적으로 문자열을 합칠 때 다음과 같은 연산을 한다고 한다.
  • 원래 문자열을 복사한다.
  • 연결시킬 새로운 문자열을 그 끝에 추가한다.
  • 원래 문자열을 새롭게 완성한 문자열로 대치시킨다.

상당히 긴 문자열의 경우 수행속도가 상당히 느려질 것 같다.

해결 방법은, 합칠 문자열을 배열에 담아 join으로 한꺼번에 합친다.




스크립트 수행 속도를 측정하기 위해서 timer() 함수를 사용한다.
timer()함수는 현재 시간을 자정에서 시작하여 지난 시간을 초단위로 리턴한다.


자세한 내용은,
출처: 개발::ASP에서 문자열 연결을 빠르게 하는 방법(http://blog.eloitcube.co.kr/47)


ASP에서는 (VBScript) 큰 따옴표를 마음대로 출력할 수가 없다.

%>"<% 이런식으로 ASP 태그를 닫아서 출력해주거나
chr(34) 함수를 이용하여 캐릭터 코드를 변환시켜서 출력해주는 수 밖에 없다.


#2008.10.28 추가

큰 따옴표를 "" 두개로 묶어주면 된다. MSSQL도 string 안에 작은 따옴표를 사용하고 싶다면 '' 두개 붙여주면 된다.
str = "<a href=""/"">home</a>"
이런식이다.



ASP Encode/Decode Functions

Methods for encoding and deconding text in various formats.


Server.URLEncode

Used for encoding data that will be passed via a querystring variable. A querystring variable is anything following the question mark (?) in the URL (location) field of your browser. You create querystring variables when you perform a redirect or build a hyperlink to another page on your site.

<a href="page2.asp?name=Joe+Schmoe">here</a>
<%
Response.Redirect "page2.asp?ID=3"
%>

In the example above, the hyperlink contains a variable named "name" which has a value of "Joe Schmoe" (the space is encoded as "+") In the Response.Redirect statement, we have a querystring variabled named "ID" with a value of 3. To perform a URL encode on a variable (for purposes of passing this variable to another page) use the following:

<a href="page2.asp?name=<%= Server.URLEncode(sName) %>">
here</a>
<%
Response.Redirect "page2.asp?ID=" &_
Server.URLEncode(nID)
%>

URLDecode

For some reason, Microsoft did not include a URL decode function with Active Server Pages. Most likely, this was because the decoding of querystring variables is done automatically for you when you access the querystring object:

<%= Request.QueryString("name") %>

For those of you who are desperately in need of this function:

' -----------------------------------------
' URL decode to retrieve the original value

Function URLDecode(sConvert)
Dim aSplit
Dim sOutput
Dim I
If IsNull(sConvert) Then
URLDecode = ""
Exit Function
End If

' convert all pluses to spaces
sOutput = REPLACE(sConvert, "+", " ")

' next convert %hexdigits to the character
aSplit = Split(sOutput, "%")

If IsArray(aSplit) Then
sOutput = aSplit(0)
For I = 0 to UBound(aSplit) - 1
sOutput = sOutput & _
Chr("&H" & Left(aSplit(i + 1), 2)) &_
Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)
Next
End If

URLDecode = sOutput
End Function

Server.HTMLEncode

This useful built-in function is very useful for encoding text that should be displayed in a form input. By "form input" we mean a web form control such as a text input, select or textarea control.

You may have noticed that certain characters cause the HTML on your web form to be interpretted incorrectly. Specifically, the HTML tag characters "<" and ">" can have this effect as well as the quote character (") which is used to encapsulate values.

<input type="text" value="<%= Server.HTMLEncode(sValue) %>">

<textarea name="sample" width=38 height=10>
<%= Server.HTMLEncode(sValue) %>
</textarea>
This simple value shows you how easy it is to safely include any value within a web form control.

HTMLDecode

Just like with the URLDecode function described previously, Microsoft, in its infinite wisdom decided not to include an HTMLDecode function with their Server component. It is a relatively simple matter to decode this test data (although I haven't had a need to do this so far.) For completeness sake, here is an HTMLDecode function you may use:

Function HTMLDecode(sText)
Dim I
sText = Replace(sText, "&quot;", Chr(34))
sText = Replace(sText, "&lt;" , Chr(60))
sText = Replace(sText, "&gt;" , Chr(62))
sText = Replace(sText, "&amp;" , Chr(38))
sText = Replace(sText, "&nbsp;", Chr(32))
For I = 1 to 255
sText = Replace(sText, "&#" & I & ";", Chr(I))
Next
HTMLDecode = sText
End Function

출처 : ASP Encode/Decode Functions
mysql에는 password()라는 내장함수가 있다.
하지만 mssql에는 다른 함수가 있다.

== 암호화 하여 튜플 삽입하기 ==
INSERT INTO MEMBERSHIP values('rE', pwdencrypt('1234'))

== 암호화된 튜플 검색하기 ==
SELECT UID FROM MEMBERSHIP WHERE 1 = pwdcompare('1111', PASSWORD)
// Return one more UID or nothing

SELECT pwdcompare('1111', PASSWORD) FROM MEMBERSHIP WHERE UID = 'rE'
// Return [0 | 1]


에러 핸들링을 하는 try ... catch (... finally) 문은 ASP에 없다. 엄밀히 말하면 VBscript엔 없다.


하지만 방법이 있다.

On Error Resume Next '// ERROR CHECKING

If err <> 0 Then '// ERROR OCCURRED
 '// 에러처리
End If

On Error Goto 0 '// Clear Errors
On Error Resume Next '// NEW ERROR CHECKING


BLOG main image
by 장혁닷컴

공지사항

카테고리

분류 전체보기 (15)
Web2.0_ (0)
게시판 (0)
Web (10)
자전거여행 (0)
Excel (1)
라임라이트 (0)
문화생활 (0)

글 보관함

달력

«   2010/09   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Total : 3,740
Today : 0 Yesterday : 0