<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ColdFire Designs</title>
	<atom:link href="http://www.coldfiredesigns.com/2010/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.coldfiredesigns.com/2010</link>
	<description>Burrrr!... It&#039;s cold in here!</description>
	<lastBuildDate>Fri, 11 May 2012 18:33:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Paging in VBScript</title>
		<link>http://www.coldfiredesigns.com/2010/?p=209</link>
		<comments>http://www.coldfiredesigns.com/2010/?p=209#comments</comments>
		<pubDate>Fri, 11 May 2012 18:33:32 +0000</pubDate>
		<dc:creator>Jason Beaudoin</dc:creator>
				<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.coldfiredesigns.com/2010/?p=209</guid>
		<description><![CDATA[Creating a paging class was probably one of the more challenging pieces logic that I&#8217;ve ever had to create. I had a very difficult time stabilizing it, and make sure that it would reliably return the results I needed. Well, &#8230; <a href="http://www.coldfiredesigns.com/2010/?p=209">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Creating a paging class was probably one of the more challenging pieces logic that I&#8217;ve ever had to create. I had a very difficult time stabilizing it, and make sure that it would reliably return the results I needed. </p>
<p>Well, after many hours of work, I got it to work quite well, and the fruits of my labour are for you to behold and possess! </p>
<p>You will note that you will require to get a recordset from the database to populate the class on your own. The class is well documented, but if you have any questions, please don&#8217;t hesitate to message me here on this blog.</p>
<p>You can <a href="http://www.coldfiredesigns.com/2010/downloads/VBScript/pagingClass.asp">download a copy of my paging class here</a>. Also, don&#8217;t forget to also <a href="http://www.coldfiredesigns.com/2010/downloads/VBScript/paging.css">download a copy of the CSS that goes with it</a>. Change it how you see fit.</p>
<p><map name='google_ad_map_209_43b5584f90dd0c5f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/209?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_209_43b5584f90dd0c5f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=209&amp;url= http%3A%2F%2Fwww.coldfiredesigns.com%2F2010%2F%3Fp%3D209' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.coldfiredesigns.com/2010/?feed=rss2&#038;p=209</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript &#8211; Title Case</title>
		<link>http://www.coldfiredesigns.com/2010/?p=203</link>
		<comments>http://www.coldfiredesigns.com/2010/?p=203#comments</comments>
		<pubDate>Fri, 11 May 2012 18:24:58 +0000</pubDate>
		<dc:creator>Jason Beaudoin</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[VBScript String Utilities]]></category>

		<guid isPermaLink="false">http://www.coldfiredesigns.com/2010/?p=203</guid>
		<description><![CDATA[Ever want to transform your string into title case? This script will get it done! This chuck of code is part of a class that I call the FormatString Class that can be downloaded here. But, here is the code &#8230; <a href="http://www.coldfiredesigns.com/2010/?p=203">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ever want to transform your string into title case? This script will get it done!</p>
<p>This chuck of code is part of a class that I call the FormatString Class that can be <a href="http://www.coldfiredesigns.com/2010/downloads/VBScript/formatString.asp">downloaded here</a>. But, here is the code by itself:</p>
<pre class="brush: vb; title: ; notranslate">
'+--------------------------------------------------------------------------------------------------
'	TITLE CASE
'	Turns a string to title case
'	. titleCase: capitalizes the first letter of every word.
'		. Usage: formatStringObject.titleCase(&quot;your title cased text&quot;);
'		. Requires: str: string to title case;
'		. Returns: &quot;Your Title Cased Text&quot;
'+--------------------------------------------------------------------------------------------------
	Function titleCase(str)

		If str &lt;&gt; &quot;&quot; Then 'Ensure that there is a string to avoid unhandled errors.

			Dim arr
			arr = Split(str, &quot; &quot;)

			For titleCaseCount = 0 To UBound(arr)
				firstLetter = UCase(Left(arr(titleCaseCount), 1))
				word = cropStart(arr(titleCaseCount))
				arr(titleCaseCount) = firstLetter &amp; word
			Next

			titleCase = Join(arr, &quot; &quot;)

		End If

	End Function
</pre>
<p><map name='google_ad_map_203_43b5584f90dd0c5f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/203?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_203_43b5584f90dd0c5f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=203&amp;url= http%3A%2F%2Fwww.coldfiredesigns.com%2F2010%2F%3Fp%3D203' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.coldfiredesigns.com/2010/?feed=rss2&#038;p=203</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript &#8211; Formating Dates</title>
		<link>http://www.coldfiredesigns.com/2010/?p=198</link>
		<comments>http://www.coldfiredesigns.com/2010/?p=198#comments</comments>
		<pubDate>Fri, 11 May 2012 18:22:38 +0000</pubDate>
		<dc:creator>Jason Beaudoin</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[VBScript String Utilities]]></category>

		<guid isPermaLink="false">http://www.coldfiredesigns.com/2010/?p=198</guid>
		<description><![CDATA[When VBScript was invented, the programmers already implemented a way to format a date, but if you&#8217;ve noticed, it was really centred along the lines of American needs, and it left out many other common ways to format a date. &#8230; <a href="http://www.coldfiredesigns.com/2010/?p=198">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When VBScript was invented, the programmers already implemented a way to format a date, but if you&#8217;ve noticed, it was really centred along the lines of American needs, and it left out many other common ways to format a date. Also, technologies like XML also demanded a new method to format a date.</p>
<p>The following two scripts allow you to format a date. The first method will convert a date into an XML safe format called RFC822. The other script will simply format a date as you specify (like d-m-y, m-d-y, y-m-d).</p>
<p>This chuck of code is part of a class that I call the FormatString Class that can be <a href="http://www.coldfiredesigns.com/2010/downloads/VBScript/formatString.asp">downloaded here</a>. But, here is the code by itself:</p>
<pre class="brush: vb; title: ; notranslate">
'+--------------------------------------------------------------------------------------------------
'	CONVERT DATE TO RFC822
' 	Returns your date in RFC822 format. Required for RSS
' 	feeds.
'	. RFC822_Date: converts a date into the RFC822 international date format. This is useful for
'				   RSS feeds because the RSS feed validators require this date format;
'		. Usage: formatStringObject.RFC822_Date(&quot;12/19/2009&quot;, &quot;EST&quot;)
'		. Requires:
'			- date: your date in mm/dd/yyyy format;
'			- date code: the international date code for your are like &quot;GMT&quot;)
'		. Returns: &quot;Sat, 19 Dec 2009 00:00:00 EST&quot;
'+--------------------------------------------------------------------------------------------------
	Public Function RFC822_Date(myDate, offset)
	   Dim myDay, myDays, myMonth, myYear
	   Dim myHours, myMinutes, myMonths, mySeconds

	   myDate = CDate(myDate)
	   myDay = WeekdayName(Weekday(myDate),true)
	   myDays = Day(myDate)
	   myMonth = MonthName(Month(myDate), true)
	   myYear = Year(myDate)
	   myHours = zeroPad(Hour(myDate), 2)
	   myMinutes = zeroPad(Minute(myDate), 2)
	   mySeconds = zeroPad(Second(myDate), 2)

	   RFC822_Date = myDay&amp;&quot;, &quot;&amp; _
									  myDays&amp;&quot; &quot;&amp; _
									  myMonth&amp;&quot; &quot;&amp; _
									  myYear&amp;&quot; &quot;&amp; _
									  myHours&amp;&quot;:&quot;&amp; _
									  myMinutes&amp;&quot;:&quot;&amp; _
									  mySeconds&amp;&quot; &quot;&amp; _
									  UCase(offset)
	End Function 

	'This supports the RFC822_Date Function
	Private Function zeroPad(m, t)
	   zeroPad = String(t-Len(m),&quot;0&quot;)&amp;m
	End Function

'+--------------------------------------------------------------------------------------------------
'	FORMAT DATE
'
' 	Requires:
'		sDate (string): 	Your Date
'		sFormat (string): 	Your desired format as in &quot;d-m-y, m-d-y, y-m-d&quot;
'+--------------------------------------------------------------------------------------------------
	Public Function formatDate(sDate, sFormat)
		searchString =&quot;/&quot;	

		indexNum 	= inStr(sDate, searchString)
		sDay 		= Left(sDate, indexNum - 1)
		sMonthYear	= Mid(sDate, indexNum + 1)
		indexNum	= inStr(sMonthYear, searchString)
		sMonth 		= Left(sMonthYear, indexNum - 1)
		sYear		= Mid(sMonthYear, indexNum + 1)	

		Select Case sFormat
			Case &quot;d-m-y&quot;
				formatDate = sDay &amp; &quot;-&quot; &amp; sMonth &amp; &quot;-&quot; &amp; sYear
			Case &quot;m-d-y&quot;
				formatDate = sMonth &amp; &quot;-&quot; &amp; sDay &amp; &quot;-&quot; &amp; sYear
			Case &quot;y-m-d&quot;
				formatDate = sYear &amp; &quot;-&quot; &amp; sMonth &amp; &quot;-&quot; &amp; sDay
			Case Else
				formatDate = Replace(sFormat, &quot;/&quot;, &quot;-&quot;)
		End Select
	End Function
</pre>
<p><map name='google_ad_map_198_43b5584f90dd0c5f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/198?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_198_43b5584f90dd0c5f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=198&amp;url= http%3A%2F%2Fwww.coldfiredesigns.com%2F2010%2F%3Fp%3D198' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.coldfiredesigns.com/2010/?feed=rss2&#038;p=198</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript &#8211; Some Useful Gets</title>
		<link>http://www.coldfiredesigns.com/2010/?p=193</link>
		<comments>http://www.coldfiredesigns.com/2010/?p=193#comments</comments>
		<pubDate>Fri, 11 May 2012 18:09:57 +0000</pubDate>
		<dc:creator>Jason Beaudoin</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[VBScript String Utilities]]></category>

		<guid isPermaLink="false">http://www.coldfiredesigns.com/2010/?p=193</guid>
		<description><![CDATA[VBScript is such a low level programming language, that sometimes I found myself creating small functions just to make shortcuts. For example, getting just the name of a page was sometimes a real pain. The following are some small scripts &#8230; <a href="http://www.coldfiredesigns.com/2010/?p=193">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>VBScript is such a low level programming language, that sometimes I found myself creating small functions just to make shortcuts. For example, getting just the name of a page was sometimes a real pain. The following are some small scripts that you may find useful. Now, I know a lot of you will say that server variables already take care of these things, but the truth is that they don&#8217;t deliver the content that you need cleanly (they always seem to leave junk in the strings that you need like the http://, or whatever).</p>
<p>The scripts are:</p>
<ul>
<li>Get Page Name</li>
<li>Get Refering Page</li>
<li>Get Refering Host</li>
<li>Get Absolute URI</li>
</ul>
<p>This chuck of code is part of a class that I call the FormatString Class that can be <a href="http://www.coldfiredesigns.com/2010/downloads/VBScript/formatString.asp">downloaded here</a>. But, here is the code by itself:</p>
<pre class="brush: vb; title: ; notranslate">
'+--------------------------------------------------------------------------------------------------
'	QUERYSTRING AND SERVER VARIABLE FUNCTIONS
'+--------------------------------------------------------------------------------------------------
	'--------------------------------------------------------
	' Gets the name of the current web page.
	'	. getPageName: gets the name of the current webpage. It goes a bit further than simply getting
	'				   the server variable &quot;Script Name&quot;;
	'		. Usage: formatStringObject.getPageName()
	'		. Requires nothing;
	'		. Returns: your current page, i.e.: &quot;yourPage.html&quot;
	'--------------------------------------------------------
	Function getPageName()
		Dim scriptName
		Dim pageName
		scriptName = Request.ServerVariables(&quot;SCRIPT_NAME&quot;)
		pageName = Mid(scriptName, inStrRev(scriptName, &quot;/&quot;) +1)
		getPageName = pageName
	End Function

	'--------------------------------------------------------
	' Get the refering page
	'	. getReferingPage: gets the name of the refering page. As with the getPageName method, it
	'					   strips the characters that you don't need from the string and only gives you
	'					   the name of the refering page.
	'		. Usage: formatStringObject.getReferingPage()
	'		. Requires nothing;
	'		. Returns: the refering page, i.e.: &quot;yourPreviousPage.html&quot;
	'--------------------------------------------------------
	Function getReferingPage()
		Dim scriptName
		Dim pageName
		scriptName = Request.ServerVariables(&quot;HTTP_REFERER&quot;)
		pageName = Mid(scriptName, inStrRev(scriptName, &quot;/&quot;) +1)
		pageName = cropWordRev(pageName, &quot;?&quot;) 'Gets rid of any querystring vars and just passes the raw refering page name.
		getReferingPage = pageName
	End Function	

	'--------------------------------------------------------
	' Provide you with the refering host
	'	. getReferingHost: get the refering host without the extra string data. Clearner than using the
	'					   server variable &quot;HTTP Referer&quot;
	'		. Usage: formatStringObject.getReferingHost()
	'		. Requires nothing;
	'		. Returns: your host, i.e.: &quot;http://www.yourwebsite.com&quot;
	'--------------------------------------------------------
	Function getReferingHost()
		Dim scriptName
		Dim serverName
		scriptName = Request.ServerVariables(&quot;HTTP_REFERER&quot;)
		serverName = Replace(scriptName, &quot;http://&quot;, &quot;&quot;)
		serverName = Replace(serverName, &quot;https://&quot;, &quot;&quot;)
		getReferingHost = cropWordRev(serverName, &quot;/&quot;)
	End Function

	'--------------------------------------------------------
	' Returns the absolute path of the current web page
	'	. getAbsoluteURI: returns the absolute path of the current web page;
	'		. Usage: formatStringObject.getAbsoluteURI()
	'		. Requires nothing;
	'		. Returns: the current absolute path of your page, i.e.: &quot;http://www.yourWebSite.com/aFolder/yourPage.html&quot;
	'--------------------------------------------------------
	Function getAbsoluteURI()
		getAbsoluteURI = &quot;http://&quot; &amp; Request.ServerVariables(&quot;HTTP_HOST&quot;) &amp; Replace(Request.ServerVariables(&quot;PATH_INFO&quot;), getPageName(), &quot;&quot;)
	End Function
</pre>
<p><map name='google_ad_map_193_43b5584f90dd0c5f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/193?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_193_43b5584f90dd0c5f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=193&amp;url= http%3A%2F%2Fwww.coldfiredesigns.com%2F2010%2F%3Fp%3D193' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.coldfiredesigns.com/2010/?feed=rss2&#038;p=193</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript &#8211; Phone Number Formating</title>
		<link>http://www.coldfiredesigns.com/2010/?p=191</link>
		<comments>http://www.coldfiredesigns.com/2010/?p=191#comments</comments>
		<pubDate>Fri, 11 May 2012 18:08:14 +0000</pubDate>
		<dc:creator>Jason Beaudoin</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[VBScript String Utilities]]></category>

		<guid isPermaLink="false">http://www.coldfiredesigns.com/2010/?p=191</guid>
		<description><![CDATA[When storing a phone number in a database, I like to make sure that I&#8217;m only storing the actual numbers. It&#8217;s never a good idea to let your user decided how they are going to format the number, because everyone &#8230; <a href="http://www.coldfiredesigns.com/2010/?p=191">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When storing a phone number in a database, I like to make sure that I&#8217;m only storing the actual numbers. It&#8217;s never a good idea to let your user decided how they are going to format the number, because everyone does it differently. For example, some people like to use brackets (as in: (888) 555-1234), some don&#8217;t (as in: 888-555-1234). So, I always strip my numbers of any non-numeric characters. The following piece of code is how I strip and reconstruct the numbers. Note that this code may not work 100% with some European country numbers. </p>
<p>This chuck of code is part of a class that I call the FormatString Class that can be <a href="http://www.coldfiredesigns.com/2010/downloads/VBScript/formatString.asp">downloaded here</a>. But, here is the code by itself:</p>
<pre class="brush: vb; title: ; notranslate">
'+--------------------------------------------------------------------------------------------------
'	PHONE NUMBER FORMATING
'+--------------------------------------------------------------------------------------------------
	'--------------------------------------------------------
	' Strips all of the formating of a number into a string
	' of digits.
	'	. cleanPhoneNumber: strips all of the formating of a string and returns just the digits.
	'		. Usage: formatStringObject.clearPhoneNumber(&quot;(123) 456-7890&quot;)
	'		. Requires: a phone number
	'		. Returns: just the digits, i.e.: &quot;1234567890&quot;
	'--------------------------------------------------------
	Function cleanPhoneNumber(ByVal num)
		Dim stringLen, newNum
		stringLen = Len(num)

		'Run thru each character and extract only the
		'number.
		If Not IsNull(num) Then 'Ensure that a number was passed and that it's not null!
			For i = 1 to stringLen
				character = Mid(num, i, 1)
				If IsNumeric(character) Then
					newNum = newNum &amp; character 'If a number, add here.
				End If
			Next
		Else
			newNum = null
		End If
		cleanPhoneNumber = newNum
	End Function

	'--------------------------------------------------------
	' Formats a series of numbers into a recognized phone
	' number format
	'	. formatPhoneNumber: formats a string of digits into a valid phone number format. Requires that the
	'						 correct number of digits be present in the string.
	'		. Usage: formatStringObject.formatPhoneNumber(&quot;123456789&quot;)
	'		. Requires:  a string of digits
	'		. Returns: a formated phone number, i.e.: &quot;(123) 456-7890&quot;. Note: if you do not supply the
	'			       right amount of digits or if it has anything other characters other than digits,
	'				   it will simply return the string unchanged.
	'--------------------------------------------------------
	Function formatPhoneNumber(ByVal num)
		Dim stringLen
		Dim firstNum
		Dim newNum

		If IsNull(num) Then num = &quot;&quot;
		num = CStr(num)

		stringLen = Len(num)
		firstNum = Left(num, 1)

		If IsNumeric(num) Then
			If stringLen = 10 Then 'If regular North American number
				newNum = &quot;(&quot; &amp; Left(num, 3) &amp; &quot;) &quot; &amp; Mid(num, 4, 3) &amp; &quot;-&quot; &amp; Mid(num, 7, 4)
			ElseIf stringLen = 11 AND firstNum = &quot;1&quot; Then 'If a regular North American long distance number.
				newNum = Left(num, 1) &amp; &quot; (&quot; &amp; Mid(num, 2, 3) &amp; &quot;) &quot; &amp; Mid(num, 5, 3) &amp; &quot;-&quot; &amp; Mid(num, 8, 4)
			ElseIf stringLen = 11 AND firstNum = &quot;0&quot; Then' If an European type number
				newNum = Left(num, 5) &amp; &quot; &quot; &amp; Mid(num, 6, 6)
			ElseIf stringLen = 12 Then 'If an over seas number.
				newNum = &quot;+&quot; &amp; Left(num, 2) &amp; &quot; &quot; &amp; Mid(num, 3, 4) &amp; &quot; &quot; &amp; Mid(num, 7, 6)
			Else
				newNum = num 'Everything else is not formated.
			End If
		End If

		formatPhoneNumber = newNum
	End Function
</pre>
<p><map name='google_ad_map_191_43b5584f90dd0c5f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/191?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_191_43b5584f90dd0c5f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=191&amp;url= http%3A%2F%2Fwww.coldfiredesigns.com%2F2010%2F%3Fp%3D191' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.coldfiredesigns.com/2010/?feed=rss2&#038;p=191</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript &#8211; Encode String to UTF-8</title>
		<link>http://www.coldfiredesigns.com/2010/?p=187</link>
		<comments>http://www.coldfiredesigns.com/2010/?p=187#comments</comments>
		<pubDate>Fri, 11 May 2012 18:02:35 +0000</pubDate>
		<dc:creator>Jason Beaudoin</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[VBScript String Utilities]]></category>

		<guid isPermaLink="false">http://www.coldfiredesigns.com/2010/?p=187</guid>
		<description><![CDATA[Ever have character encoding problems? I have! &#8230;and it can be a real pain in the ass when your old database is plagued by data that is not compatible with the UTF-8 character encoding of your new web page. Here &#8230; <a href="http://www.coldfiredesigns.com/2010/?p=187">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ever have character encoding problems? I have! &#8230;and it can be a real pain in the ass when your old database is plagued by data that is not compatible with the UTF-8 character encoding of your new web page. Here is some code that has helped me over the years. I am not the author of the code (and if you find out who they are, let me know and I&#8217;ll give them credit here), but I thought I&#8217;d post them here as they have helped me out over the years.</p>
<p>This chuck of code is part of a class that I call the FormatString Class that can be <a href="http://www.coldfiredesigns.com/2010/downloads/VBScript/formatString.asp">downloaded here</a>. But, here is the code by itself:</p>
<pre class="brush: vb; title: ; notranslate">
'+--------------------------------------------------------------------------------------------------
'	ENCODE UTF8
' 	Note: this is not the same as encoding a string that
' 	is already in ANSI format. See ANSIToUnicode for
' 	that functionality
'	. Encode_UTF8: encodes a new string into UTF8 format. Note that this is not the same as encoding
'				   a string that is already in ANSI format. See ANSIToUnicode for that functionality.
'		. Usage: formatStringObject.encode_UTF8(your string)
'		. Requires:  a string of characters to format
'		. Returns: the same string in UTF8 format
'+--------------------------------------------------------------------------------------------------
	Public Function Encode_UTF8(astr)
		Dim c
		Dim utftext
		utftext = &quot;&quot;
		If isNull(astr) = false or astr &lt;&gt; &quot;&quot; Then
			astr = Replace(astr, &quot;’&quot;, &quot;'&quot;) 'replacing the apostrophe
			astr = Replace(astr, &quot;–&quot;, &quot;-&quot;) 'replacing the emdash with minus sign
			For n = 1 To Len(astr)
				c = Asc(Mid(astr, n, 1))
				If c &lt; 128 Then
					utftext = utftext + Mid(astr, n, 1)
				ElseIf ((c &gt; 127) And (c &lt; 2048)) Then
					utftext = utftext + Chr(((c \ 64) Or 192))
					utftext = utftext + Chr(((c And 63) Or 128))
				Else
					utftext = utftext + Chr(((c \ 144) Or 234))
					utftext = utftext + Chr((((c \ 64) And 63) Or 128))
					utftext = utftext + Chr(((c And 63) Or 128))
				End If
			Next
		End If
		Encode_UTF8 = utftext
	End Function

'+--------------------------------------------------------------------------------------------------
' Converts an ANSI string to Unicode
'	. ANSIToUnicode: encodes an ANSI string to UTF8 format.
'		. Usage: formatStringObject.ansiToUnicode(your string)
'		. Requires:  an ANSI string to format
'		. Returns:  the same string in UTF8 format
'+--------------------------------------------------------------------------------------------------
	Public Function ANSIToUnicode(ByRef pbinBinaryData)
		Dim lbinData	' Binary Data (ANSI)
		Dim llngLength	' Length of binary data (byte count)
		Dim lobjRs		' Recordset
		Dim lstrData	' Unicode Data
		' VarType Reference
		'8 = Integer (this is expected var type)
		'17 = Byte Subtype
		' 8192 = Array
		' 8209 = Byte Subtype + Array

		Set lobjRs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
		If VarType(pbinBinaryData) = 8 Then
			' Convert integers(4 bytes) to Byte Subtype Array (1 byte)
			llngLength = LenB(pbinBinaryData)
			If llngLength = 0 Then
				lbinData = ChrB(0)
			Else
				Call lobjRs.Fields.Append(&quot;BinaryData&quot;, adLongVarBinary, llngLength)
				Call lobjRs.Open()
				Call lobjRs.AddNew()
				Call lobjRs.Fields(&quot;BinaryData&quot;).AppendChunk(pbinBinaryData &amp; ChrB(0)) ' + Null terminator
				Call lobjRs.Update()
				lbinData = lobjRs.Fields(&quot;BinaryData&quot;).GetChunk(llngLength)
				Call lobjRs.Close()
			End If
		Else
			lbinData = pbinBinaryData
		End If
		' Do REAL conversion now!
		llngLength = LenB(lbinData)
		If llngLength = 0 Then
			lstrData = &quot;&quot;
		Else
			Call lobjRs.Fields.Append(&quot;BinaryData&quot;, adLongVarChar, llngLength)
			Call lobjRs.Open()
			Call lobjRs.AddNew()
			Call lobjRs.Fields(&quot;BinaryData&quot;).AppendChunk(lbinData)
			Call lobjRs.Update()
			lstrData = lobjRs.Fields(&quot;BinaryData&quot;).Value
			Call lobjRs.Close()
		End If

		Set lobjRs = Nothing
		ANSIToUnicode = lstrData

	End Function
</pre>
<p><map name='google_ad_map_187_43b5584f90dd0c5f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/187?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_187_43b5584f90dd0c5f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=187&amp;url= http%3A%2F%2Fwww.coldfiredesigns.com%2F2010%2F%3Fp%3D187' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.coldfiredesigns.com/2010/?feed=rss2&#038;p=187</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make a String Safe for XML</title>
		<link>http://www.coldfiredesigns.com/2010/?p=180</link>
		<comments>http://www.coldfiredesigns.com/2010/?p=180#comments</comments>
		<pubDate>Fri, 11 May 2012 17:39:17 +0000</pubDate>
		<dc:creator>Jason Beaudoin</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[VBScript String Utilities]]></category>

		<guid isPermaLink="false">http://www.coldfiredesigns.com/2010/?p=180</guid>
		<description><![CDATA[Ensuring that text is safe for XML is always a good rule of thumb when your data is being generated by a group or by people who are not technical. The following code does exactly that. I will ensure that &#8230; <a href="http://www.coldfiredesigns.com/2010/?p=180">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ensuring that text is safe for XML is always a good rule of thumb when your data is being generated by a group or by people who are not technical. The following code does exactly that. I will ensure that text is stripped and replaced with any offending characters.</p>
<p>This chuck of code is part of a class that I call the FormatString Class that can be <a href="http://www.coldfiredesigns.com/2010/downloads/VBScript/formatString.asp" data-mce-href="/2010/downloads/VBScript/formatString.asp">downloaded here</a>. But, here is the code by itself:</p>
<pre class="brush: vb; title: ; notranslate">
'+--------------------------------------------------------------------------------------------------
'	XMLSafe
'	Transformed a string to XML safe format.
'+--------------------------------------------------------------------------------------------------
	Function XMLSafe(str)
		Dim xmlList
		xmlList = getXMLList()
		If InStr(str, &quot;Ã©&quot;) &gt; 0 Then str = Replace(str, &quot;Ã©&quot;, &quot;é&quot;)
		xmlSafe = ChangeCharacters(str, xmlList, 3)
	End Function

	'Support for the XMLSafe function. Creates a list of characters to use to make the xml equivalent switch.
	Function getXMLList()
		Dim s 	

		s = s &amp; &quot;&amp;Aacute;,193,C1,Á|&quot;
		s = s &amp; &quot;&amp;aacute;,225,E1,á|&quot;
		s = s &amp; &quot;&amp;Acirc;,194,C2,Â|&quot;
		s = s &amp; &quot;&amp;acirc;,226,E2,â|&quot;
		s = s &amp; &quot;&amp;acute;,180,B4,´|&quot;
		s = s &amp; &quot;&amp;AElig;,198,C6,Æ|&quot;
		s = s &amp; &quot;&amp;aelig;,230,E6,æ|&quot;
		s = s &amp; &quot;&amp;Agrave;,192,C0,À|&quot;
		s = s &amp; &quot;&amp;agrave;,224,E0,à|&quot;
		s = s &amp; &quot;&amp;Aring;,197,C5,Å|&quot;
		s = s &amp; &quot;&amp;aring;,229,E5,å|&quot;
		s = s &amp; &quot;&amp;Atilde;,195,C3,Ã|&quot;
		s = s &amp; &quot;&amp;atilde;,227,E3,ã|&quot;
		s = s &amp; &quot;&amp;Auml;,196,C4,Ä|&quot;
		s = s &amp; &quot;&amp;auml;,228,E4,ä|&quot;
		s = s &amp; &quot;&amp;bdquo;,132,84,„|&quot;
		s = s &amp; &quot;&amp;brvbar;,166,A6,¦|&quot;
		s = s &amp; &quot;&amp;bull;,149,95,•|&quot;
		s = s &amp; &quot;&amp;Ccedil;,199,C7,Ç|&quot;
		s = s &amp; &quot;&amp;ccedil;,231,E7,ç|&quot;
		s = s &amp; &quot;&amp;cedil;,184,B8,¸|&quot;
		s = s &amp; &quot;&amp;cent;,162,A2,¢|&quot;
		s = s &amp; &quot;&amp;circ;,136,88,ˆ|&quot;
		s = s &amp; &quot;&amp;copy;,169,A9,©|&quot;
		s = s &amp; &quot;&amp;curren;,164,A4,¤|&quot;
		s = s &amp; &quot;&amp;dagger;,134,86,†|&quot;
		s = s &amp; &quot;&amp;Dagger;,135,87,‡|&quot;
		s = s &amp; &quot;&amp;deg;,176,B0,°|&quot;
		s = s &amp; &quot;&amp;divide;,247,F7,÷|&quot;
		s = s &amp; &quot;&amp;Eacute;,201,C9,É|&quot;
		s = s &amp; &quot;&amp;eacute;,233,E9,é|&quot;
		s = s &amp; &quot;&amp;Ecirc;,202,CA,Ê|&quot;
		s = s &amp; &quot;&amp;ecirc;,234,EA,ê|&quot;
		s = s &amp; &quot;&amp;Egrave;,200,C8,È|&quot;
		s = s &amp; &quot;&amp;egrave;,232,E8,è|&quot;
		s = s &amp; &quot;&amp;ETH;,208,D0,Ð|&quot;
		s = s &amp; &quot;&amp;eth;,240,F0,ð|&quot;
		s = s &amp; &quot;&amp;Euml;,203,CB,Ë|&quot;
		s = s &amp; &quot;&amp;euml;,235,EB,ë|&quot;
		s = s &amp; &quot;&amp;euro;,128,80,€|&quot;
		s = s &amp; &quot;&amp;fnof;,131,83,ƒ|&quot;
		s = s &amp; &quot;&amp;frac12;,189,BD,½|&quot;
		s = s &amp; &quot;&amp;frac14;,188,BC,¼|&quot;
		s = s &amp; &quot;&amp;frac34;,190,BE,¾|&quot;
		s = s &amp; &quot;&amp;hellip;,133,85,…|&quot;
		s = s &amp; &quot;&amp;Iacute;,205,CD,Í|&quot;
		s = s &amp; &quot;&amp;iacute;,237,ED,í|&quot;
		s = s &amp; &quot;&amp;Icirc;,206,CE,Î|&quot;
		s = s &amp; &quot;&amp;icirc;,238,EE,î|&quot;
		s = s &amp; &quot;&amp;iexcl;,161,A1,¡|&quot;
		s = s &amp; &quot;&amp;Igrave;,204,CC,Ì|&quot;
		s = s &amp; &quot;&amp;igrave;,236,EC,ì|&quot;
		s = s &amp; &quot;&amp;iquest;,191,BF,¿|&quot;
		s = s &amp; &quot;&amp;Iuml;,207,CF,Ï|&quot;
		s = s &amp; &quot;&amp;iuml;,239,EF,ï|&quot;
		s = s &amp; &quot;&amp;laquo;,171,AB,«|&quot;
		s = s &amp; &quot;&amp;ldquo;,147,93,“|&quot;
		s = s &amp; &quot;&amp;lsaquo;,139,8B,‹|&quot;
		s = s &amp; &quot;&amp;lsquo;,145,91,‘|&quot;
		s = s &amp; &quot;&amp;macr;,175,AF,¯|&quot;
		s = s &amp; &quot;&amp;mdash;,45,97,—|&quot;
		s = s &amp; &quot;&amp;micro;,181,B5,µ|&quot;
		s = s &amp; &quot;&amp;middot;,183,B7,•|&quot;
		s = s &amp; &quot;&amp;nbsp;,160,A0, |&quot;
		s = s &amp; &quot;&amp;ndash;,45,96,–|&quot;
		s = s &amp; &quot;&amp;not;,172,AC,¬|&quot;
		s = s &amp; &quot;&amp;Ntilde;,209,D1,Ñ|&quot;
		s = s &amp; &quot;&amp;ntilde;,241,F1,ñ|&quot;
		s = s &amp; &quot;&amp;Oacute;,211,D3,Ó|&quot;
		s = s &amp; &quot;&amp;oacute;,243,F3,ó|&quot;
		s = s &amp; &quot;&amp;Ocirc;,212,D4,Ô|&quot;
		s = s &amp; &quot;&amp;ocirc;,244,F4,ô|&quot;
		s = s &amp; &quot;&amp;OElig;,140,8C,Œ|&quot;
		s = s &amp; &quot;&amp;oelig;,156,9C,œ|&quot;
		s = s &amp; &quot;&amp;Ograve;,210,D2,Ò|&quot;
		s = s &amp; &quot;&amp;ograve;,242,F2,ò|&quot;
		s = s &amp; &quot;&amp;ordf;,170,AA,ª|&quot;
		s = s &amp; &quot;&amp;ordm;,186,BA,º|&quot;
		s = s &amp; &quot;&amp;Oslash;,216,D8,Ø|&quot;
		s = s &amp; &quot;&amp;oslash;,248,F8,ø|&quot;
		s = s &amp; &quot;&amp;Otilde;,213,D5,Õ|&quot;
		s = s &amp; &quot;&amp;otilde;,245,F5,õ|&quot;
		s = s &amp; &quot;&amp;Ouml;,214,D6,Ö|&quot;
		s = s &amp; &quot;&amp;ouml;,246,F6,ö|&quot;
		s = s &amp; &quot;&amp;para;,182,B6,¶|&quot;
		s = s &amp; &quot;&amp;permil;,137,89,‰|&quot;
		s = s &amp; &quot;&amp;plusmn;,177,B1,±|&quot;
		s = s &amp; &quot;&amp;pound;,163,A3,£|&quot;
		s = s &amp; &quot;&amp;raquo;,187,BB,»|&quot;
		s = s &amp; &quot;&amp;rdquo;,148,94,”|&quot;
		s = s &amp; &quot;&amp;reg;,174,AE,®|&quot;
		s = s &amp; &quot;&amp;rsaquo;,155,9B,›|&quot;
		s = s &amp; &quot;&amp;rsquo;,146,',’|&quot;
		s = s &amp; &quot;&amp;sbquo;,130,82,‚|&quot;
		s = s &amp; &quot;&amp;Scaron;,138,8A,Š|&quot;
		s = s &amp; &quot;&amp;scaron;,154,9A,š|&quot;
		s = s &amp; &quot;&amp;sect;,167,A7,§|&quot;
		s = s &amp; &quot;&amp;shy;,173,AD,¬|&quot;
		s = s &amp; &quot;&amp;sup1;,185,B9,¹|&quot;
		s = s &amp; &quot;&amp;sup2;,178,B2,²|&quot;
		s = s &amp; &quot;&amp;sup3;,179,B3,³|&quot;
		s = s &amp; &quot;&amp;szlig;,223,DF,ß|&quot;
		s = s &amp; &quot;&amp;THORN;,222,DE,Þ|&quot;
		s = s &amp; &quot;&amp;thorn;,254,FE,þ|&quot;
		s = s &amp; &quot;&amp;tilde;,152,98,˜|&quot;
		s = s &amp; &quot;&amp;times;,215,D7,×|&quot;
		s = s &amp; &quot;&amp;trade;,153,99,™|&quot;
		s = s &amp; &quot;&amp;Uacute;,218,DA,Ú|&quot;
		s = s &amp; &quot;&amp;uacute;,250,FA,ú|&quot;
		s = s &amp; &quot;&amp;Ucirc;,219,DB,Û|&quot;
		s = s &amp; &quot;&amp;ucirc;,251,FB,û|&quot;
		s = s &amp; &quot;&amp;Ugrave;,217,D9,Ù|&quot;
		s = s &amp; &quot;&amp;ugrave;,249,F9,ù|&quot;
		s = s &amp; &quot;&amp;uml;,168,A8,¨|&quot;
		s = s &amp; &quot;&amp;Uuml;,220,DC,Ü|&quot;
		s = s &amp; &quot;&amp;uuml;,252,FC,ü|&quot;
		s = s &amp; &quot;&amp;Yacute;,221,DD,Ý|&quot;
		s = s &amp; &quot;&amp;yacute;,253,FD,ý|&quot;
		s = s &amp; &quot;&amp;yen;,165,A5,¥|&quot;
		s = s &amp; &quot;&amp;yuml;,159,9F,Ÿ|&quot;
		s = s &amp; &quot;&amp;yuml;,255,FF,ÿ&quot;
		s = s &amp; &quot;&amp;#39;,',','&quot;
		s = s &amp; &quot;&lt;ul&gt;,,,&quot;
		s = s &amp; &quot;&lt;li&gt;, - , - , - &quot;
		s = s &amp; &quot;&lt;/li&gt;,,,&quot;
		s = s &amp; &quot;&lt;/ul&gt;,,,&quot;

		getXMLList = s
	End Function

	'Supports the XMLSafe function. This simply switches the characters from one to another.
	Function ChangeCharacters(str, dict, intColumn)
		Dim arr(), arrTemp, a
		Dim n, i

		arrTemp = Split(dict, &quot;|&quot;)

		Redim arr(2, UBound(arrTemp))

		For n = 0 To UBound(arrTemp) -1
			a = Split(arrTemp(n), &quot;,&quot;)
			If str &lt;&gt; &quot;&quot; Then
				If InStr(str, a(0)) &gt; 0 Then
					str = Replace(str, a(0), Chr(a(1)))
				End If
			End If
		Next

		ChangeCharacters = str
	End Function
</pre>
<p><map name='google_ad_map_180_43b5584f90dd0c5f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/180?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_180_43b5584f90dd0c5f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=180&amp;url= http%3A%2F%2Fwww.coldfiredesigns.com%2F2010%2F%3Fp%3D180' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.coldfiredesigns.com/2010/?feed=rss2&#038;p=180</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Array.Push in VBScript</title>
		<link>http://www.coldfiredesigns.com/2010/?p=172</link>
		<comments>http://www.coldfiredesigns.com/2010/?p=172#comments</comments>
		<pubDate>Wed, 19 Oct 2011 19:33:24 +0000</pubDate>
		<dc:creator>Jason Beaudoin</dc:creator>
				<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.coldfiredesigns.com/2010/?p=172</guid>
		<description><![CDATA[For those of you who develop in PHP and Javascript (and I&#8217;m sure it exists in other languages as well), the Array.Push method is something that is lacking in VBScript. Many other people have tried to implement a method to &#8230; <a href="http://www.coldfiredesigns.com/2010/?p=172">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For those of you who develop in PHP and Javascript (and I&#8217;m sure it exists in other languages as well), the Array.Push method is something that is lacking in VBScript. Many other people have tried to implement a method to achieve this; some better than others.</p>
<p>This is my solution below.</p>
<p>Eventually, I&#8217;ll be putting this into an Array class that I will distribute on here. For now, here is the function that I&#8217;ve created to push data into an array.</p>
<h2>Features:</h2>
<ul>
<li>It can push content into a 1 dimensional array or a 2 dimensional matrix.</li>
<li>You can pass an existing array to the push function or an empty variable (that intend on becoming your array)</li>
<li>You can pass a string or an array to push. If you push an array, it expects that the array is a row to add to the array.</li>
</ul>
<h2>Usage</h2>
<p>push(yourArray, yourData)</p>
<p><strong>Requires:</strong></p>
<ul>
<li>yourArray As Array or yourEmptyVar: A variable that will be passed to the function By Reference that is either an array or an empty variable. The returned item will be an array (naturally);</li>
<li>yourData As Array or a variable containing any type of data: The information that is to be added to your array. If it&#8217;s an array, it will expect that the data is in the form of a row (meaning that this array contains one row (y axis)  and multiple columns (x axis)).</li>
</ul>
<h2>Example:</h2>
<pre class="brush: vb; title: ; notranslate">
Dim myArray

Call push(myArray, &quot;some data&quot;)

Function push(ByRef arr, ByVal row)
	Dim cellValue
	Dim r: r=0
	Dim c: c=0
	Dim dummyVar

	If IsArray(arr) Then

		On Error Resume Next
		dummyVar = UBound(arr, 2) 'Determine if it's a 2D matrix.

		If (CLng(Err.Number) &gt; 0) = TRUE Then ' 1D arrays go thru here.
			On Error Goto 0
			c = UBound(arr) + 1
			Redim Preserve arr(c)
			arr(UBound(arr)) = row

		Else 'Matrices go through here.
			On Error Goto 0
			Redim Preserve arr(UBound(arr), UBound(arr, 2) + 1) 'add a row
			If IsArray(row) Then
				For r = 0 To UBound(row) ' run thru each column in row
					arr(r, UBound(arr,2)) = row(r) 'add the cell
				Next
			Else
				arr(0, UBound(arr,2)) = row
			End If

		End If

	Else

		If IsArray(row) Then
			If UBound(row) &lt; 2 Then 'If this is an array, then it should only contain one row.
				arr = row
			End If
		Else
			Redim arr(0)
			arr(0) = row
		End If

	End If

	If IsArray(arr) Then push = UBound(arr)

End Function
</pre>
<p><map name='google_ad_map_172_43b5584f90dd0c5f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/172?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_172_43b5584f90dd0c5f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=172&amp;url= http%3A%2F%2Fwww.coldfiredesigns.com%2F2010%2F%3Fp%3D172' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.coldfiredesigns.com/2010/?feed=rss2&#038;p=172</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cryptography Class: Encrypt a String in VBScript</title>
		<link>http://www.coldfiredesigns.com/2010/?p=161</link>
		<comments>http://www.coldfiredesigns.com/2010/?p=161#comments</comments>
		<pubDate>Wed, 19 Oct 2011 16:50:06 +0000</pubDate>
		<dc:creator>Jason Beaudoin</dc:creator>
				<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.coldfiredesigns.com/2010/?p=161</guid>
		<description><![CDATA[Introducing the Cryptography Class: this is a method to encrypt a string using nothing but VBScript, and it doesn&#8217;t require any installed components. It&#8217;s based on one of the simplest cipher methods known as the Vernum Cipher, and although it would &#8230; <a href="http://www.coldfiredesigns.com/2010/?p=161">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Introducing the <a title="Cryptography Class" href="http://www.coldfiredesigns.com/2010/downloads/VBScript/encrypt.asp">Cryptography Class</a>: this is a method to encrypt a string using nothing but VBScript, and it doesn&#8217;t require any installed components. It&#8217;s based on one of the simplest cipher methods known as the Vernum Cipher, and although it would take some time for a hacker to crack, I wouldn&#8217;t rely on it solely to protect data. It merely adds another layer of security.</p>
<p>I used it to encrypt my data going from one page to another. If I really want to protect my data from phishing techniques, I encrypt the data coming from my form and then decrypt it once it reaches the server.</p>
<p>This code was mostly developed by <a title="4GuysFromRolla" href="http://www.4guysfromrolla.com/ASPScripts/PrintPage.asp?REF=%2Fwebtech%2F110599-1.2.shtml">4GuysFromRolla</a>, and I adapted their code into this class.</p>
<p>The Vernam Cipher was invented by none other than Gilbert Vernam (he was an AT&amp;T engineer), in 1918. The ciphertext is generated by combining ASCII plaintext with a &#8220;one-time pad&#8221; or key. The key is combined with the plaintext stream by mod 2 (Xor), thus creating the encrypted cyphertext.</p>
<p><a title="Download the Cryptography Class now!" href="http://www.coldfiredesigns.com/2010/downloads/VBScript/encrypt.asp">Download the Cryptography Class now!</a></p>
<h2>Features</h2>
<ul>
<li>Uses an encryption key. Without this key you will not be able to decrypt your data.</li>
<li>You can optionally set an application GUID variable and the encryption will add that to the complexity of the encryption.</li>
</ul>
<h2>Usage</h2>
<p><strong>Encrypt<br />
</strong>cryptographyObject.Encrypt(yourString as String)<br />
Encrypts your string</p>
<p><strong>Decrypt</strong><br />
cryptographyObject.Decrypt(yourString as String)<br />
Decrypts your string</p>
<h2>Options</h2>
<p><strong>Key</strong><br />
cryptographyObject.Key = &#8220;yourEncrptionKey&#8221;<br />
Sets an encription key of your choice.</p>
<p><strong>GUID</strong><br />
cryptographyObject.GUID = &#8220;yourGUIDserial as GUID&#8221;<br />
Set a GUID serial number. Careful! If you use this, ensure that your using it as an Application variable so that you can decrypt it server site, because GUIDs are generated randomly upon request, so if it doesn&#8217;t match, the decrypting won&#8217;t work.</p>
<h2>Example:</h2>
<pre class="brush: vb; title: ; notranslate">
	Dim Encrypt
	Dim regularString
	Dim encryptedString
	Dim encryptionKey

	Set Encrypt = New Cryptography

	Application(&quot;GUID&quot;)	= GetGuid

	regularString 		= &quot;&quot;&quot;The world was my oyster, but I used the wrong fork.&quot;&quot; -- Oscar Wilde&quot;
	encryptionKey 		= &quot;ClockWorkOrange&quot;
	Encrypt.key 	= encryptionKey 'Required.
	Encrypt.GUID 	= Application(&quot;GUID&quot;) 'This is optional.
	encryptedString 	= Encrypt.Encrypt(regularString)

	Response.Write(&quot;&lt;strong&gt;This is the original string:&lt;/strong&gt; &quot; &amp; regularString) &amp; &quot;&lt;br /&gt;&lt;br /&gt;&quot;
	Response.Write(&quot;&lt;strong&gt;This is the string encrypted:&lt;/strong&gt; &quot; &amp; encryptedString) &amp; &quot;&lt;br /&gt;&lt;br /&gt;&quot;
	Response.Write(&quot;&lt;strong&gt;This is the string decrypted:&lt;/strong&gt; &quot; &amp; Encrypt.Decrypt(encryptedString)) &amp; &quot;&lt;br /&gt;&lt;br /&gt;&quot;
	Response.Write(&quot;&lt;strong&gt;This is the application GUID:&lt;/strong&gt; &quot; &amp; Application(&quot;GUID&quot;))

	Function GetGuid()
		Dim TypeLib
        Set TypeLib = CreateObject(&quot;Scriptlet.TypeLib&quot;)
        GetGuid = Left(CStr(TypeLib.Guid), 38)
        Set TypeLib = Nothing
    End Function 

	Set Encrypt = NOTHING
</pre>
<p><a title="Download the Cryptography Class now!" href="http://www.coldfiredesigns.com/2010/downloads/VBScript/encrypt.asp">Download the Cryptography Class now!</a></p>
<p><map name='google_ad_map_161_43b5584f90dd0c5f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/161?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_161_43b5584f90dd0c5f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=161&amp;url= http%3A%2F%2Fwww.coldfiredesigns.com%2F2010%2F%3Fp%3D161' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.coldfiredesigns.com/2010/?feed=rss2&#038;p=161</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript Validate Class</title>
		<link>http://www.coldfiredesigns.com/2010/?p=146</link>
		<comments>http://www.coldfiredesigns.com/2010/?p=146#comments</comments>
		<pubDate>Wed, 19 Oct 2011 15:22:00 +0000</pubDate>
		<dc:creator>Jason Beaudoin</dc:creator>
				<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.coldfiredesigns.com/2010/?p=146</guid>
		<description><![CDATA[I know that Classic ASP is now considered very old, but there are still some applications out there built on it. In the next few weeks, I&#8217;ll be uploading some classes that I created that may prove useful to some &#8230; <a href="http://www.coldfiredesigns.com/2010/?p=146">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I know that Classic ASP is now considered very old, but there are still some applications out there built on it. In the next few weeks, I&#8217;ll be uploading some classes that I created that may prove useful to some users supporting older applications.</p>
<p>As my first segment, I&#8217;m sharing the <a title="Validate Class" href="http://www.coldfiredesigns.com/2010/downloads/VBScript/validateClass.asp">Validate Class</a>. This class validates variables usually from querystrings or form posts. As a security measure, <strong>all</strong> developers should be checking their variables before sending their data to the database, and <strong>all</strong> data should be considered dangerous. It&#8217;s just a best practice and highly recommended.</p>
<p><a title="Download the Validate Class now!" href="http://www.coldfiredesigns.com/2010/downloads/VBScript/validateClass.asp">Download the Validate Class now!</a></p>
<h2>Features</h2>
<p>The class validates:</p>
<ul>
<li>data type</li>
<li>length</li>
<li>malicious keywords or groups of characters like:</li>
<ul>
<li>script</li>
<li>;&#8211;</li>
<li>/*</li>
<li>*/</li>
<li>@@</li>
<li>nchar</li>
<li>varchar</li>
<li>nvarchar</li>
<li>delete</li>
<li>execute</li>
<li>sysobjects</li>
<li>syscolumns</li>
<li>information_schema</li>
</ul>
<li>Detects and converts strings that are encoded hexadecimally.</li>
</ul>
<h2>Usage</h2>
<p><strong>Method:</strong> Validate(yourString, dataType, stringLength)</p>
<p><strong>Requires:</strong></p>
<ul>
<li>yourString (any type of data): the string that you wish to validate</li>
<li>dataType (as string): the datatype that you are expecting. Supported types are:</li>
<ul>
<li>number: a numeric expression</li>
<li>username: alphanumeric, foreign and some special characters</li>
<li>email: any email. Must contain &#8220;@&#8221; and a &#8220;.&#8221;</li>
<li>url: any URL</li>
<li>password: alphanumeric and special characters. Cannot contain any spaces;</li>
<li>name: alphanumeric and foreign characters and spaces</li>
<li>session: only validates hex characters and dashes. Anything else is rejected.</li>
<li>desc: alphanumeric, foreign and special characters, spaces</li>
<li>alphanum: alphanumeric characters only</li>
<li>date: any valid date (according to VBScript)</li>
<li>serial:  alphanumeric and some special characters</li>
<li>off: turns off character validation (but still validates length and for harmful words)</li>
</ul>
<li>length (as integer): the length that you are expecting.</li>
</ul>
<h2>Example:</h2>
<pre class="brush: vb; title: ; notranslate">
	Dim cleanerTool
	Dim dirtyString
	Dim cleanString

	dirtyString = Request.QueryString(&quot;id&quot;) 'Get your dirty data... I'm expecting an numerical id.

	Set cleanerTool = New Validate 'Create the validation instance.
	cleanString = cleanerTool.validate(dirtyString, &quot;number&quot;, 6) 'Clean the mofo!
	Set cleanerTool = NOTHING 'Clean up some memory (always important in Classic)

	Response.Write cleanString
</pre>
<p>(BTW, just as a side note, I don&#8217;t write my code in the Hungarian Style. I just believe that a variable name should be written in a self explanatory way. It&#8217;s just my way.)</p>
<p><a title="Download the Validate Class now!" href="http://www.coldfiredesigns.com/2010/downloads/VBScript/validateClass.asp">Download the Validate Class now!</a></p>
<p><map name='google_ad_map_146_43b5584f90dd0c5f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/146?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_146_43b5584f90dd0c5f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=146&amp;url= http%3A%2F%2Fwww.coldfiredesigns.com%2F2010%2F%3Fp%3D146' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.coldfiredesigns.com/2010/?feed=rss2&#038;p=146</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

