Change Case
I am pretty new to CF and I am having difficulty getting a function to work the way I need it to. It's working to convert to title case unless a single lowercase string is used. I think I need to add something to have it check string length and if it is only on character, convert automatically. Not sure how to accomplish this. Any help would be greatly appreciated.
Here is the code:
<cffunction name="titleCase" access="public" returntype="string">
<cfargument name="str" type="string" required="yes" />
<cfset var retStr = "" />
<cfset var idx = "" />
<cfloop list="#arguments.str#" delimiters=" " index="idx">
<cfset retStr = listAppend(retStr, ucase(left(idx,1)) & lcase(right(idx,Len(idx)-1))," ") />
</cfloop>
<cfreturn retStr />
</cffunction>