CFLib.org – Common Function Library Project

parseQuotedPrintable(text)

Last updated January 10, 2007

author

Isaac Dealey

Version: 1 | Requires: CF6 | Library: StrLib

Description:
Allows a string which is encoded with the Quoted-Printable format to be converted into UTF-8 for parsing various document formats such as vCard and iCal.

Return Values:
Returns a string.

Example:

<cfoutput>#ParseQuotedPrintable("1=3D1")#</cfoutput>

Parameters:

Name Description Required
text String to parse. Yes

Full UDF Source:

<!---
 Converts a string of text from Quoted-Printable format to UTF-8.
 
 @param text 	 String to parse. (Required)
 @return Returns a string. 
 @author Isaac Dealey (info@turnkey.to) 
 @version 1, January 10, 2007 
--->
<cffunction name="parseQuotedPrintable" output="false">
	<cfargument name="text" type="string" required="true">
	<cfset var crlf = chr(13) & chr(10)>
	<cfset var char = "">
	<cfset var x = 0>
	
	<cfset text = ListToArray(crlf & text,"=")>
	<cfloop index="x" from="1" to="#arrayLen(text)#">
		<cfset char = left(text[x],2)>
		<cfset text[x] = removechars(text[x],1,2)>
		<cfif char is not crlf>
			<cfset text[x] = CHR(InputBaseN(char, 16)) & text[x]>
		</cfif>
	</cfloop>
	
	<cfreturn ArrayToList(text,"")>
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson