CFLib.org – Common Function Library Project

stringToHex(str)

Last updated May 8, 2006

author

Chris Dary

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Counterpart to HexToString - converts an ASCII string to hexadecimal.

Return Values:
Returns a string.

Example:

<cfoutput>#stringToHex("hello")#</cfoutput>

Parameters:

Name Description Required
str String to convert to hex. Yes

Full UDF Source:

/**
 * Counterpart to HexToString - converts an ASCII string to hexadecimal.
 * 
 * @param str 	 String to convert to hex. (Required)
 * @return Returns a string. 
 * @author Chris Dary (umbrae@gmail.com) 
 * @version 1, May 8, 2006 
 */
function stringToHex(str) {
	var hex = "";
	var i = 0;
	for(i=1;i lte len(str);i=i+1) {
		hex = hex & right("0" & formatBaseN(asc(mid(str,i,1)),16),2);
	}
	return hex;
}
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