– Common Function Library Project

chrex(value[, charset][, radix])

Last updated July 15, 2004


Hiroshi Okugawa

Version: 1 | Requires: CF6 | Library: StrLib

Charset attribute enabled extended chr function.

Return Values:
Returns a string.


<cfoutput>#chrex("53 4A 49 53 82 CC 95 B6  8E 9A 0D 0A")#</cfoutput>
<cfoutput>#chrex("a4 a2 a4 a4 a4 a6 a4 a8 a4 aa", "EUCJP")#</cfoutput>
<cfoutput>#chrex("144 86", "MS932", "10")#</cfoutput>


Name Description Required
value Value to encode. Yes
charset Character set. Defaults to systems default. No
radix Radix for value. No

Full UDF Source:

 Charset attribute enabled extended chr function.
 @param value 	 Value to encode. (Required)
 @param charset 	 Character set. Defaults to systems default. (Optional)
 @param radix 	 Radix for value. (Optional)
 @return Returns a string. 
 @author Hiroshi Okugawa ( 
 @version 1, July 15, 2004 
<cffunction name="chrex" return="string" output="false">
  <cfargument name="value" type="string" required="true">
  <cfargument name="charset" type="string" required="false" default="">
  <cfargument name="radix" type="numeric" required="false" default="16">
  <cfset var a="">
  <cfset var tmp="">
  <cfset var st = "">
  <cfset var integer = "">
  <cfset var string = "">
  <cfset var byte = "">
  <cfset var system = "">
  <cfobject type="java" class="java.util.StringTokenizer" action="create" name="st">
  <cfobject type="java" class="java.lang.Integer" action="create" name="integer">
  <cfobject type="java" class="java.lang.String" action="create" name="string">
  <cfobject type="java" class="java.lang.Byte" action="create" name="byte">

  <cfif not len(arguments.charset)>
    <cfobject type="java" class="java.lang.System" action="create" name="system">
    <cfset arguments.charset=system.getProperty("file.encoding")>
  <cfset a=arraynew(1)>
  <cfset st.init(arguments.value, " ,#chr(9)#")>
  <cfloop condition="#st.hasMoreTokens()#">
    <cfset tmp=integer.parseInt(st.nextToken(), arguments.radix)>
    <cfset arrayappend(a, byte.init(tmp))>
  <cfreturn string.init(a, arguments.charset)>
blog comments powered by Disqus


Latest Additions

Kevin Cotton added
May 5, 2016

Raymond Camden added
April 25, 2016

Chris Wigginton added
January 18, 2016

Gary Stanton added
November 19, 2015

Sebastiaan Naafs - van Dijk added
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson