View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > Chr PreviousNext

Chr

Converts a numeric value to a UCS-2 character.

A character with the specified UCS-2 character code.

String functions

Chr(number) 

Asc

ColdFusion MX: Changed Unicode support: ColdFusion supports the Java UCS-2 representation of Unicode characters, up to a value of 65535. (Earlier releases supported 1-255.)

Parameter

Description

number

A value (a number in the range 0 to 65535, inclusive)

The values 0 - 31 are standard, nonprintable codes. For example:

Note: For a complete list of the Unicode characters and their codes, see www.unicode.org/charts/.

<!--- If the character string is not empty, then
      output its Chr value --->
<cfif IsDefined("form.charVals")>
      <cfoutput>#form.charVals# = #Chr(form.charVals)#</cfoutput>
</cfif>

<cfform action="#CGI.script_name#" method="POST">
   <p>Type an integer character code from 1 to 65535<br>
      to see its corresponding character.<br>
   <cfinput type="Text" 
      name="CharVals" 
      range="1,65535" 
      message="Please enter an integer from 1 to 65535" 
      validate="integer" 
      required="Yes" 
      size="5" 
      maxlength="5"
      >
<p><input type="Submit" name=""> <input type="RESET">
</cfform>

Contents > CFML Reference > ColdFusion Functions > Chr PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


csteinola said on Jan 5, 2005 at 1:24 PM :
The charts on the unicode site reference characters by Hex number. It would be nice if the Chr() function accepted Hex values.

Regardless, I've been trying to output a micro(n) symbol using Chr(). The unicode site states that the hex value is "00B5" (listed in the "Latin-1 Supplement"). Translating that to decimal, 181, and using that - Chr(181) - the output appears to be "µ" (Latin Capital Letter A with Circumflex AND the Micro Sign), rather than just the micro symbol.
marnen said on Aug 15, 2005 at 7:40 AM :
1. You can use InputBaseN to convert hex to decimal. See http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/funct119.htm .

2. Unicode characters won't display properly unless you specify the proper document encoding in the header.

3. Why use chr() for this purpose? Character entities -- &#xxx; -- are much easier to work with.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functi35.htm