What is isupper macros in C?

I want to know how the "isupper" macro is defined in C / C ++. Could you please provide me with the same or point to available resources. I tried looking at ctype.h but could not understand.

+3
source share
4 answers

This implementation is defined - each provider can and usually does it differently.

The most commonly used table of “signs” is an array with one element for each symbol, the value of this element, which is a collection of flags, indicates the details of the symbol. An example is:

 traits[(int) 'C'] = ALPHA | UPPER | PRINTABLE;

In this case, isupper () will look something like this:

 #define isupper(c) ((traits[(int)(c)] & UPPER) == UPPER)
+12
source

, . isupper() , locale , .

ASCII - , , . ASCII 0x41 0x5A , .

+5

. :

extern char *__isupper;
#define isupper(x) ((int)__isupper[(x)])

__isupper 0 1, . , ABI, POSIX.

ASCII UTF-8:

#define isupper(x) ((unsigned)(x)-'A'<='Z'-'A')
+5

, , GCC. isupper ( ), :

#define isupper (c) (c >= 'A') (c <= 'Z')

http://ideone.com/GlN05

GCC 0: 1 :

(* __ ctype_b_loc()) [(int) (c)] (unsigned short int) (1 < (0))

__ctype_b_loc() - , , .

+1

Source: https://habr.com/ru/post/1757949/


All Articles