Copy link to clipboard
Copied
Hi, I would like to find a function that check if a string is all written in Uppercase and if so, to capitalize it.
I'll capitalize it with CSS using: text-transform: capitalize, but the only coldfusion function I found on line check only a character:
<cfscript>
function isUpperCase(char) {
if (Asc(char) gte 65 and Asc(char) lte 90)
return true;
return false;
}
</cfscript>
Someone is able to write it in a way that check if a whole string is UPPERCASE ?
I'm not able to ... I should study, I know, but I'm in hurry ...
The IS operator does a case insensitive comparison. Use the compare() function instaed.
Copy link to clipboard
Copied
Uppercase the string using the UCase() function and then check if it is identical to the original string.
Copy link to clipboard
Copied
Do you meaqn checking something like:
<cfif string is UCase(string)> ?
It seems not working ...
Copy link to clipboard
Copied
The IS operator does a case insensitive comparison. Use the compare() function instaed.
Copy link to clipboard
Copied
This does work fine:
<cfif compare(string,UCase(string)) is 0><span style="text-transform: capitalize;">#lcase(string)#</span><cfelse>#string#</cfif>
Thank you!