Issue
In https://github.com/php/php-src/pull/10771#discussion_r1130059596 I was pointed out that inet_pton
and inet_ntop
UNIX functions can be locale dependent as they are documented so.
However, the output format of these functions is well defined so my question is, are they really locale dependent and can someone point me to a configuration/library where they have non-standard format?
Solution
The threat you linked has a bad interpretation of MT-Safe locale
. It is about type of safety, not about locale/culture/etc.
But it is also possible both functions depend on locale: if I remember correctly the only condition about charset is that \0
and /
are fixed (and C
has a requirement that digits 0
to 9
use consecutive encoding values). And each locale can defin own charset. In any case, I think most program just assume ASCII (or a subset of ASCII). But it is so seldom that I'm not sure I interpret LC_TYPE
correctly. Maybe there is stronger assumption on charset in POSIX.
And you can make both function portable. The non-portable way is was just a shortcut: if you know the structure of long and of each byte of the IP (as in IP packets) you could have a optimized version. But since many years (few decades) compilers will optimize also the portable code.
Answered By - Giacomo Catenazzi Answer Checked By - Candace Johnson (WPSolving Volunteer)