I was trying to get the thousand separator used in Portuguese-speaking countries, on Windows, compiling my C code with GCC. For this, I was using locale.h's function
setlocale(int category, const char* locale)
, and then localeconv()->thousands_sep
.
The GCC manual says the locale names are system-specific. The Microsoft's documentation says that the following options are functionally equivalent, though the first is the recommended one.
setlocale( LC_ALL, "en-US" );
setlocale( LC_ALL, "English" );
setlocale( LC_ALL, "English_United States.1252" );
As I was trying to use Portuguese, I had tried setlocale( LC_ALL , "pt-BR" );
. The thousand separator was NULL, which is not usually Portuguese's thousand separator. But when I tried setlocale( LC_ALL, "portuguese" )
, it worked!
But... What are the correct locale names on Windows? using GCC, if the compiler matters. Or, is my GCC broken? Or maybe Windows, or maybe me. Or is Microsoft's documentation wrong =]