islower

islower

한 문자가 소문자인지 확인할 때 써요. <ctype.h>의 문자 분류 함수 중 하나예요.

출처: cppreference

본문

문법 (Syntax)

int islower ( int ch );

설명 (Explanation)

현재 C 로케일 기준으로 주어진 문자가 소문자로 분류되는지 확인해요. 기본 "C" 로케일에서는 소문자(abcdefghijklmnopqrstuvwxyz)에 대해서만 true를 반환해요.

islowertrue를 반환하면, 같은 C 로케일에서 같은 문자에 대해 iscntrl, isdigit, ispunct, isspacefalse를 반환한다는 것이 보장돼요.

ch의 값이 unsigned char로 표현할 수 없고 EOF와도 같지 않으면 동작이 정의되지 않아요.

매개변수 (Parameters)

  • ch — 분류할 문자

반환값 (Return value)

문자가 소문자면 0이 아닌 값, 아니면 0을 반환해요.

예시 (Example)

기본 로케일과 ISO-8859-1 로케일에서 \xe5(å)의 분류가 달라지는 걸 보여줘요.

#include <ctype.h>
#include <locale.h>
#include <stdio.h>

int main(void)
{
    unsigned char c = '\xe5'; // letter å in ISO-8859-1
    printf("In the default C locale, \\xe5 is %slowercase\n",
           islower(c) ? "" : "not " );
    setlocale(LC_ALL, "en_GB.iso88591");
    printf("In ISO-8859-1 locale, \\xe5 is %slowercase\n",
           islower(c) ? "" : "not " );
}

가능한 출력 (Possible output):

In the default C locale, \xe5 is not lowercase
In ISO-8859-1 locale, \xe5 is lowercase

참고 문헌 (References)

  • C23 표준 (ISO/IEC 9899:2024): 7.4.1.7 The islower function (p: TBD)
  • C17 표준 (ISO/IEC 9899:2018): 7.4.1.7 The islower function (p: 146)
  • C11 표준 (ISO/IEC 9899:2011): 7.4.1.7 The islower function (p: 202)
  • C99 표준 (ISO/IEC 9899:1999): 7.4.1.7 The islower function (p: 183)
  • C89/C90 표준 (ISO/IEC 9899:1990): 4.3.1.6 The islower function

더 알아보기

  • 와이드 문자 버전인 iswlower(C95)도 있어요.
  • 소문자를 대문자로 바꾸려면 toupper를, 대문자 판별은 isupper를 보세요.
  • cppreference 원문에서 islower의 자세한 내용을 확인할 수 있어요.