Quoted-printable decode VBScript function.
ActiveX RegEdit.   ActiveX User account Manager   Pure-ASP Upload
Export MDB/DBF from ASP   Active LogFile   WebChecker   ActiveX/ASP Multi Dictionary object
 See 
 also 
 IISTracer, real-time IIS monitor and logging tool.
 Huge ASP file upload with progress bar. 



Do you like this article?
Please, rate it
and write review!
Rated:
by Aspin.com users
What do you think?
 Top messages
 22.3.2003 19:18:41 
 Read and write SQL image data, store binary file to sql table. (nbsp;WSHDatabaseConversionVBScript)
 4.5.2002 9:16:43 
 Send an email from ASP (WSH) using VBSscript, CDONTS and Outlook. (nbsp;ASP / ASP.NetWSHVBScriptEmail)
 22.3.2003 17:07:03 
 Work with binary files in VBSscript - read and write local and remote files (nbsp;WSHFile & data transferFunctionsVBScript)

 Quoted-printable decode VBScript function. 

 Areas>ASP / ASP.Net>Functions>Conversion
 Areas>Languages>VBScript
See it online at Quoted-printable decoder sample page.
     This article contains a short function for quoted printable decoding, using CDO.Message object. You can use this function in ASP or .VBS files (wsh - windows scripting host files), or directly in VBA (visual basic 5, 6, Word, Excel, Access and Outlook scripting).
'VBScript QuotedPrintableDecode decoding Function
'2005 Antonin Foller http://www.motobit.com
Function QuotedPrintableDecode(SourceData, CharSet)
  'Create CDO.Message object For the encoding.
  Dim Message: Set Message = CreateObject("CDO.Message")

  'Set the encoding
  Message.BodyPart.ContentTransferEncoding = "quoted-printable"
  
  'Get the data stream To write source string data
  Dim Stream 'As ADODB.Stream
  Set Stream = Message.BodyPart.GetEncodedContentStream
  If VarType(SourceData) = vbString Then
    'Write the VBScript string To the stream.
    Stream.WriteText SourceData
  Else
    'Set the type of the stream To adTypeBinary.
    Stream.Type = 1
    'Write the source binary data To the stream.
    Stream.Write SourceData
  End If
  
  'Store the data To the message BodyPart
  Stream.Flush
  
  'Get an encoded stream
  Set Stream = Message.BodyPart.GetDecodedContentStream
  
  'Set the type of the stream To adTypeBinary.
  Stream.CharSet = CharSet
  
  'You can use Read method To get a binary data.
  QuotedPrintableDecode = Stream.ReadText
End Function
     Next is a binary variant of the function, with bytearray (VT_UI1 VT_ARRAY) as output. The QuotedPrintableDecode_Binary then converts the binary data to a Quoted-Printable output string. Output of this function are binary decoded data (you can use it, for example, as a data parameter of Response.BinaryWrite method) You can simply modify these two functions for combination of binary and string input and output parameters. This function is used on Quoted-printable decoder online sample page.
'VBScript QuotedPrintableDecode_Binary decoding Function
'2005 Antonin Foller http://www.motobit.com
Function QuotedPrintableDecode_Binary(SourceData)
  'Create CDO.Message object For the encoding.
  Dim Message: Set Message = CreateObject("CDO.Message")

  'Set the encoding
  Message.BodyPart.ContentTransferEncoding = "quoted-printable"
  
  'Get the data stream To write source string data
  Dim Stream 'As ADODB.Stream
  Set Stream = Message.BodyPart.GetEncodedContentStream
  If VarType(SourceData) = vbString Then
    'Write the VBScript string To the stream.
    Stream.WriteWritetext SourceData
  Else
    'Set the type of the stream To adTypeBinary.
    Stream.Type = 1
    'Write the source binary data To the stream.
    Stream.Write SourceData
  End If
  
  'Store the data To the message BodyPart
  Stream.Flush
  
  'Get an encoded stream
  Set Stream = Message.BodyPart.GetDecodedContentStream
  
  'Set the type of the stream To adTypeBinary.
  Stream.Type = 1
  
  'You can use Read method To get a binary data.
  QuotedPrintableDecode_Binary = Stream.Read
End Function

Quoted-printable

From Wikipedia, the free encyclopedia.

Quoted-printable is an encoding using printable characters, alphanumeric and the equals sign "=", to transmit 8bit data over a 7bit data path. It is defined as a MIME content transfer encoding for use in Internet e-mail.

Introduction

The basic Internet e-mail transmission protocol, SMTP, supports only ASCII characters (see also 8BITMIME). MIME defines mechanisms for sending other kinds of information in e-mail, including text in languages other than English using character encodings other than ASCII. However these encodings often use byte values outside the ASCII range so they need to be encoded further before they are suitable for use in e-mail. Quoted-printable encoding is one method used for mapping arbitary bytes into sequences of ASCII characters. This encoding is reversible, meaning the original bytes and hence the non-ASCII characters they represent can be recovered.

Quoted-printable and Base64 are the two basic MIME content transfer encodings. If the input text is mostly ASCII, quoted-printable results in a fairly readable and compact encoded result. On the other hand if the input is not mostly ASCII then quoted printable becomes both unreadable and extremely inefficient. Base64 is not readable but has a predictable overhead for all data and is the more sensible choice for binary formats or text in non latin based languages.

Quoted Printable Encoding

Any 8-bit byte value may be encoded with 3 characters, an "=" followed by two hexadecimal digits (0-9 or A-F) representing the byte's numeric value. For example, a US-ASCII form feed character (decimal value 12) can be represented by "=0C", and a US-ASCII equal sign (decimal value 61) is represented by "=3D". All characters except printable ASCII characters or end of line characters must be encoded in this fashion.

Printable ASCII characters except "=", i.e. those with decimal values between 33 and 126 excepting decimal value 61 (=), may be represented by themselves.

ASCII tab and space characters, decimal values 9 and 32, may be represented by themselves except if these characters appear at the end of a line. If one of these characters appears at the end of a line it must be encoded as "=09" (tab) or "=20" (space).

If the data being encoded contains meaningful line breaks, they must be encoded as an ASCII CR LF sequence, not as their original byte values. Conversely if byte values 10 and 13 have meanings other than end of line then they must be encoded as =0A and =0D.

Lines of quoted-printable encoded data must not be longer than 76 characters. To satisfy this requirement without altering the encoded text soft line breaks may be added as desired. A soft line break consists of an "=" at the end of an encoded line and does not cause a line break in the decoded text.

 
 

See also for 'Quoted-printable decode VBScript function.' article:

     Quoted-printable encode VBScript function. This article contains a short function for quoted printable encoding, using CDO.Message object.
     Base64 encode VBS function (vb encoder algorithm), source code Source of VBS (ASP) function that lets you encode source data (binary or string) to a base64 encoded string.
     Base64 decode VBS function (vb decoder algorithm), source code Source of VBS (ASP) function that enables decode base64 encoded strings.

If you like this page, please include next link on your pages:
<A
 Href="http://www.motobit.com/tips/detpg_quoted-printable-decode/"
 Title="This article contains a short function
  for quoted printable decoding, using
  CDO.Message object."
>Quoted-printable decode VBScript function.</A>

     IISTracer - IIS ISAPI real-time monitor IISTracer is a real-time monitoring tool for Microsoft IIS, which will show/log you what is happenning on IIS server right now. It let's you reveal problems with long-running scripts (.asp, .cgi, cfm...), hang-up states and low resource situations and lets you stop long-running requests (uploads/downloads).      ActiveX User account Manager - Set of simple objects for creating, deleting, and managing user accounts, groups, servers and domains in the Windows NT environment.
     Active log file - Hi-performance text file logging for ASP/VBS/VBA applications. Lets you create daily/weekly/monthly log files with variable number of logged values and extra timing and performance info.      ActiveX windows registry editor - Intuitive, easy to use COM interface to windows registry. Set of classes to read/enumerate/modify windows registry keys and values from ASP, VBS and T-SQL.
     ActiveX/ASP Multi Dictionary object - Free-threaded hi-speed dictionary algorithm with unique/nonunique keys (map/multimap). Connect to another dictionary object in the same process. Lock and Unlock methods to synchronize tasks (application scope). Share ASP Application/Session objects.      Export DBF/MDB from ASP - Conversion from recordset to MDB/DBF. Direct binary output of MDB or DBF files from ASP pages with one row of code.
     Pure-ASP upload - lets you upload files using Pure ASP VBS code (using multipart/form-data and input type=file).      ByteArray - Works with safearray binary data (VT_UI1 | VT_ARRAY) - save/restore binary data from disk, find, work with code pages, convert to string/hexstring(SQL).
     WebChecker - Checks http, https, ftp and gopher internet connections in regular intervals. Lets you monitor web site functionality (uptime). Enables restart or notification on problems.      HTTPLog ISAPI filter - Lets you log incomming/outgoing http header and document data to separate files. Monitor of IIS service input/output.

© 1996 – 2010 Antonin Foller, PSTRUH Software, e-mail help@pstruh.cz