Rob Bond
Rob Bond

Reputation: 33

How to output octal values in ColdFusion

I have a series of octal values I'd like to output in their ASCII character equivalents. CHR does not seem to recognize an octal character when it sees it. Is there any straightforward way of doing this with ColdFusion?

Upvotes: 3

Views: 134

Answers (1)

Peter Boughton
Peter Boughton

Reputation: 112230

Use InputBaseN to convert from Octal to Decimal, then you can use Chr to output the character.

For example:

Chr(InputBaseN( 101 , 8 ))    => A


To go back the other way, you can reverse the process with Asc and FormatBaseN:

FormatBaseN( Asc('A') , 8 )   => 101

Upvotes: 5

Related Questions