Comment 5 for bug 55293

Revision history for this message
In , AleksanderAdamowski (aadamowski) wrote :

Specifically, on UNIX systems the setlocale() function should be used to first initialize the program's running locale settings in accordance with its environment, then the same function should be used to get locale settings for specific category:

/* Sample program */
#include <locale.h>
#include <stdio.h>

int main() {
  printf("LC_ALL: %s\n", setlocale(LC_ALL, NULL));
  printf("LC_CTYPE: %s\n", setlocale(LC_CTYPE, NULL));
  printf("LC_MEASUREMENT: %s\n", setlocale(LC_MEASUREMENT, NULL));
  printf("LC_IDENTIFICATION: %s\n", setlocale(LC_IDENTIFICATION, NULL));

  /* Initialize program's locale: */
  printf("LC_ALL: %s\n", setlocale(LC_ALL, ""));

  printf("LC_ALL: %s\n", setlocale(LC_ALL, NULL));
  printf("LC_CTYPE: %s\n", setlocale(LC_CTYPE, NULL));
  printf("LC_MEASUREMENT: %s\n", setlocale(LC_MEASUREMENT, NULL));
  printf("LC_IDENTIFICATION: %s\n", setlocale(LC_IDENTIFICATION, NULL));
  return 0;
}
/* End sample */

More details:

http://www.opengroup.org/onlinepubs/009695399/functions/setlocale.html