Skip to content

Instantly share code, notes, and snippets.

@colematt
Created February 26, 2024 19:03
Show Gist options
  • Save colematt/cc235555c0bc4bf095e48e1c72918daf to your computer and use it in GitHub Desktop.
Save colematt/cc235555c0bc4bf095e48e1c72918daf to your computer and use it in GitHub Desktop.
[Get locale as a string] #c
#include <locale.h>
#include <stdio.h>
int main(int argc, char* argv[]){
setlocale(LC_ALL, "");
printf("LC_ALL: %s\n", setlocale(LC_ALL, NULL));
printf("LC_CTYPE: %s\n", setlocale(LC_CTYPE, NULL));
return 0;
}
@colematt
Copy link
Author

colematt commented Feb 26, 2024

If locale is an empty string, "", each part of the locale that should be modified is set according to the environment variables. ... If locale is NULL, the current locale is only queried, not modified.

-- man -s 3 setlocale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment