So we all know that calling setlocale()
will cause lots of C runtime functions to change their behaviour depending on the currently active locale. For example, when using a German locale, strtod()
will suddenly expect a comma to separate the integer from the fractional part of a number because that's the way floating point numbers are notated in German.
What I'm looking for is a complete list of all C runtime functions that are potentially affected by a call to setlocale()
. The man pages of setlocale mention some functions but the list is far from complete, e.g. strtod()
isn't mentioned there at all.
Why am I looking for such a list? I need to transition several projects from the portable "C" locale to the system's locale and I don't want to break anything so I need to grep for all C runtime functions that are potentially affected by a locale change in order to adapt or fix the code to be compatible with an arbitrary locale instead of just the portable "C" locale.
I don't think this exists, but POSIX lists some functions that are directly dependant of locale and locale-relative variables The Open Group Base Specifications Issue 7, 2018 edition, 7 Locale. I don't think this is exhaustive (I'm retty sure it is not). It is said:
The standard utilities in the Shell and Utilities volume of POSIX.1-2017 shall base their behavior on the current locale, as defined in the ENVIRONMENT VARIABLES section for each utility. The behavior of some of the C-language functions defined in the System Interfaces volume of POSIX.1-2017 shall also be modified based on a locale selection.
Which means (to me): read the manual of the functions...
You also have information about this in the standard C : 7.11.1 Locale control :
7.11.1 Locale control
7.11.1.1 The
setlocale
functionThe setlocale function selects the appropriate portion of the program’s locale as specified by the category and locale arguments. The setlocale function may be used to change or query the program’s entire current locale or portions thereof. The value
LC_ALL
for category names the program’s entire locale; the other values for category name only a portion of the program’s locale.LC_COLLATE
affects the behavior of thestrcoll
andstrxfrm
functions.LC_CTYPE
affects the behavior of the character handling functions, see 7.4) and the multibyte and wide character functions.LC_MONETARY
affects the monetary formatting information returned by thelocaleconv
function.LC_NUMERIC
affects the decimal-point character for the formatted input/output functions and the string conversion functions, as well as the nonmonetary formatting information returned by the localeconv function.LC_TIME
affects the behavior of thestrftime
andwcsftime
functions.
and
7.4 Character handling
7.4.1 Character classification functions
7.4.1.1 The
isalnum
function7.4.1.2 The
isalpha
function7.4.1.3 The
isblank
function7.4.1.4 The
iscntrl
function7.4.1.5 The
isdigit
function7.4.1.6 The
isgraph
function7.4.1.7 The
islower
function7.4.1.8 The
isprint
function7.4.1.9 The
ispunct
function7.4.1.10 The
isspace
function7.4.1.11 The
isupper
function7.4.1.12 The
isxdigit
function7.4.2 Character case mapping functions
7.4.2.1 The
tolower
function7.4.2.2 The
toupper
function