Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

isUppercase(string) ?

Guest
Nov 06, 2009 Nov 06, 2009

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 ...

TOPICS
Advanced techniques
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Nov 06, 2009 Nov 06, 2009

The IS operator does a case insensitive comparison. Use the compare() function instaed.

Translate
Advocate ,
Nov 06, 2009 Nov 06, 2009

Uppercase the string using the UCase() function and then check if it is identical to the original string.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2009 Nov 06, 2009

Do you meaqn checking something like:

<cfif string is UCase(string)> ?

It seems not working ...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 06, 2009 Nov 06, 2009

The IS operator does a case insensitive comparison. Use the compare() function instaed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2009 Nov 06, 2009
LATEST

This does work fine:

<cfif compare(string,UCase(string)) is 0><span style="text-transform: capitalize;">#lcase(string)#</span><cfelse>#string#</cfif>

Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources