Convert Numbers to Text using ColdFusion and ICU4J
A client requested that we spell out numbers on their website in order to clarify some financial totals. I initially planned on using the ColdFusion NumberAsString UDF from 2002. After reviewing the results, I thought I’d compare them against a unit test that I had written for ICU4J (java).
In the end I decided to use ICU4J because:
ICU4J converts text using 180+ locales. Numbers are translated to each language (Chinese, Thai, French, Spanish, etc)
UDF adds title case capitalization to all number strings. (if needed, you can do this separately.)
UDF doesn't support negative values and will throw a CF error.
UDF doesn't use hyphenized numbers ("Forty Three" versus "forty-three")
UDF uses “cardinal-verbose” format w/o hyphened numbers (Adds the word "and" where commas should be.)
UDF decimal places are treated as positive-type number words (instead of using "point four three" for ".43")
Here's some sample ColdFusion CFML code. (Download the NumberAsString UDF if you want to compare results.)













