Differences between SAA C and POSIX C locales

In fact, there are three built-in locales, S370 C, SAA C, and POSIX C. The default locale at your site depends on the system that is running the application. Issuing setlocale(LC_ALL,"") sets the default, based on the current environment. Issuing setlocale(LC_ALL,"SAA") sets the SAA C locale, even when you are running with the POSIX(ON) runtime option. Likewise, setlocale(LC_ALL,"POSIX") sets the POSIX locale.

If you are running in a C locale, one way you can determine if the SAA C or the POSIX locale is in effect is to check if the cent sign (¢ at X'4A') is defined as a punctuation character. Under the default POSIX support, the cent sign is not part of the POSIX portable character set. Figure 1 (sample CCNGDL1) shows how to perform this test.

Figure 1. Determining which locale is in effect
/* this example shows how to determine whether the SAA C or POSIX */
/* locale is in effect */

#include <stdio.h>
#include <ctype.h>
int main(void)
{
    if (ispunct(0x4A)) {
        printf(" cent sign is punct\n");
        printf(" current locale is SAA- or S370-like\n");
    }
    else {
        printf(" cent sign is not punct\n");
        printf(" default locale is POSIX-like\n");
    }
return(0);
}
Under the SAA or System/370 default locales, the lowercase letters collate before the uppercase letters; under the POSIX definition, the lowercase letters collate after the uppercase letters. The locale "" is the same locale as the one obtained from setlocale(LC_ALL,""). For more detail on these special environment variables, see Using environment variables. Other differences between the SAA C locale and the POSIX C locale are as follows:
<mb_cur_max>
The POSIX C locale is built using coded character set IBM®-1047, with <mb_cur_max> as 1. The SAA C locale is built using coded character set IBM-1047, with <mb_cur_max> as 4.
The cent sign
In the default POSIX support, the cent sign (¢) is not part of the POSIX portable character set; in the SAA locale, it is defined as a punctuation character.
Collation weight by case
In the POSIX definition, the lowercase letters collate after the uppercase letters; in the SAA or System/370 default locales, the lowercase letters collate before the uppercase letters.
LC_CTYPE category
The SAA C locale has all the EBCDIC control characters defined in the 'cntrl' class. The POSIX C locale has only the ASCII control characters in the 'cntrl' class. The SAA C locale includes ¢ (the cent character) and ¦ (the broken vertical line) as 'punct' characters. The POSIX C locale does not group these characters as 'punct' characters.
LC_COLLATE category
The default collation for the SAA C locale is the EBCDIC sequence. The POSIX C locale uses the ASCII collation sequence; the first 128 ASCII characters are defined in the collation sequence, and the remaining EBCDIC characters are at the end of the collating sequence.
LC_TIME category
The SAA C locale uses the date and time format (d_t_fmt) as "%Y/%M/%D %X"; the POSIX C locale uses "%a %b %d %H/%M/%S %Y". The SAA C locale uses the strings "am" and "pm"; the POSIX C locale uses "AM" and "PM".