Hi :)
The context is a cross-platform email application. Text can arrive encoded in any one of a large number of encodings, and similarly be sent out in the encoding that the recipient has deemed as the preferred encoding.
Because it's cross-platform, I'm using iconv (shipped by default on the Mac) to do the test for "can we decode this format to something the local platform can display", and similarly in reverse. The iconv call requires a 'from' and 'to' encoding specification. Depending on direction, the "local default" encoding spec is what I'm trying to find with the above.
Now I could just say "It's a Mac, we'll use UTF-8", but every other platform responds to either the nl_langinfo() call, or at least one of the environment variables are set. Seems odd that the platform I'm developing it on is the one that doesn't provide the API :)
Having said all that...
On the Mac, the design for the email app is going to closely follow that of Mail.app - where there's a LaunchAgent that handles all the background stuff and is the only thing with permission to actually read email content. The application (iOS or MacOS) will interact with the launchAgent over XPC, and if the launchAgent has a "Terminal.app" kind of environment rather than the restricted one I see for Applications, I could obtain the LANG variable contents after launching the app, via an XPC call.
Topic:
App & System Services
SubTopic:
Core OS