On Wed, 2025-07-23 at 19:11 -0700, Jeff Davis wrote: > The patch feels a bit over-engineered, but I'd like to know what you > think. It would be great if you could test/debug the windows NLS- > enabled paths.
Let me explain how it ended up looking over-engineered, and perhaps someone has a simpler solution. For gettext, we already configure the encoding with bind_textdomain_codeset(). All it needs is LC_MESSAGES set properly, which can be done with uselocale(), as a semi-permanent setting until the next GUC change, just like setlocale() today. There are a couple minor problems for platforms without uselocale(). For windows, we could just permanently do: _configthreadlocale(_ENABLE_PER_THREAD_LOCALE) and then use _wsetlocale. For NetBSD, I don't have a solution, but perhaps we can just reject new lc_messages settings after startup, or just defer the problem until threading actually becomes a pressing issue. The main problem is with strerror_r(). To get the right LC_MESSAGES setting, we need the separate path for windows (which has neither uselocale() nor strerror_l()). Because we need to keep track of that path anyway, I used it for gettext as well to have a cleaner separation for the entire message translation locale. That means we can avoid permanent locale settings, and reduce the chances that we accidentally depend on the global locale. Regards, Jeff Davis