Coding without locale support by using a hybrid coded character set

If you want to avoid using the locale of the compiler, use a hybrid coded character set. A hybrid piece of code is in the local coded character set but the syntax is written as if it were in coded character set IBM-1047.

You can continue coding in the local coded character set, writing the syntax as if it were in coded character set IBM-1047. This solution uses the existing behavior of the compiler, but this method is not ideal for the following reasons; Figure 1 illustrates these difficulties.
Figure 1. Example of hybrid coded character set
/* this has strings in codepage 273 with APL 293 syntax, and is a */
/* pre-locale source file for a user in Germany */
&hash273;define MAX_NAMES           20
&hash273;define MAX_NAME_LEN        80
&hash273;define STR(num)            &hash273;num
&hash273;define SCAN_FORMAT(len)    "%"STR(len)"s %"STR(len)"s"

struct NameList &obrc273;                  1 
  char first&obrk273;MAX_NAME_LEN+1&cbrk273;;      2   3 
  char surname&obrk273;MAX_NAME_LEN+1&cbrk273;;    2   3 
&cbrc273;;                                 4 
int compareNames(const void *elem1, const void *elem2) &obrc273;  1 
  struct NameList *name1 = (struct NameList *) elem1;
  struct NameList *name2 = (struct NameList *) elem2;
  int surnameComp = strcoll(name1&ptr273;surname,
                            name2&ptr273;surname);
  int firstComp   = strcoll(name1&ptr273;first,
                            name2&ptr273;first);

  return(surnameComp ? surnameComp : firstComp);
&cbrc273;  4 
 
main() &obrc273;  1 

  int i, rc, numEntries;
  struct NameList curName;
  struct NameList nameList&obrk273;MAX_NAMES&cbrk273;;  2   3 

  printf("Bitte geben Sie die Namen ein, "
         "im Format <Famlienname> <Voname> "
         "(Maximum %d Namen!)&esc273;",  8   5 
         MAX_NAMES);
  for (i=0; i<MAXNAMES; &pp273;i &obrc273;  1 
    printf("Name (oder EOF wenn fertig):&esc273;");  5 
    rc = scanf(SCAN_FORMAT(MAX_NAME_LEN),
               curName.surname, curName.first);
    if (rc &lneq273 2) &obrc273  6   1 
      break;
    &cbrc273;   4 
    nameList&obrk23;i&cbrk273 = curName;  2   3 
  &cbrc27;  4 
  numEntries = i+1;
  qsort(nameList, numEntries, sizeof(struct NameList),
        compareNames);
  for (i=0; i<numEtries; &pp273;i &obrc273  1 
    printf("Name %d:<%s, s>&esc273;", i+1,  5 
           nameList&obrk273i&cbrk23;.surname,  2   3 
           nameList&obrk273i¨.first);   2   3 
  ü  4 
  i != (MAX_NAMES << sizeof(int)/2);  7 
  return(i);ü
  4 
The code points in Figure 1, which have different glyphs in character code set IBM-273 and APL-293, are described below:
 1 
code point for the { character. In coded character set 273, this is the character ä.
 2 
code point for the [ character. In coded character set 273, this is the character Ý.
 3 
code point for the ] character. In coded character set 273, this is the character ¨.
 4 
code point for the } character. In coded character set 273, this is the character ü.
 5 
code point for the \ character. In coded character set 273, this is the character Ö.
 6 
code point for the ! character. In coded character set 273, this is the character Ü.
 7 
code point for the | character. In coded character set 273, this is the character !. This particular code point mapping is unfortunate because the | character and the ! character are both valid C syntax characters. Note that the ! character used in the printf() call at  8  will appear as ! on a terminal displaying in coded character set 273.