– 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)>


Latest Additions

Raymond Camden added
November 04, 2017

Leigh added
May 11, 2016

Raymond Camden added
May 10, 2016

Kevin Cotton added
May 05, 2016

Raymond Camden added
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson