Skip to main content
11 events
when toggle format what by license comment
Sep 18 at 16:51 audit First answers
Sep 18 at 18:45
Sep 15 at 23:14 audit First answers
Sep 15 at 23:14
Sep 15 at 4:19 audit First answers
Sep 15 at 4:20
Sep 10 at 11:56 audit First answers
Sep 10 at 11:56
Sep 4 at 8:59 audit First answers
Sep 4 at 9:00
Sep 3 at 5:15 audit First answers
Sep 3 at 5:15
Aug 27 at 12:16 comment added QuestionablePresence This comes really close to my imagined answer of "just set it before the conversion and then revert to old locale after conversion", but since it's thread-specific, even better. Depending on performance requirements and/or overhead I'd suggest simply having a thread with the locale set that's only there for these conversions. Yes, it'd require some wrapper setup to have an easy-to-use function, so the set-convert-unset may be more practical
Aug 26 at 22:27 comment added Homer512 @IanAbbott I guess it should work but I don't see what it would give you unless there is reason to believe that newlocate(…, "C", …) is more expensive. The potential downside I see is that there is a risk that you get the order wrong; maybe a global constructor called setlocale before you could access it. However, duplicating followed by newlocale(…, base) (which, confusingly, modifies the base in-place) would be good to override only parts of the locale, e.g. the numeric mask while keeping other parts set to the current locale
Aug 26 at 22:22 history edited Homer512 CC BY-SA 4.0
Fixes mask constant (no effect but now conforming to the man page)
Aug 26 at 15:59 comment added Ian Abbott I wonder if C_LOCALE = duplocale(LC_GLOBAL_LOCALE); would work? This assumes the global locale is valid (and equal to the C locale) before the first call to setlocale(), even though the POSIX spec says "If the locobj argument is LC_GLOBAL_LOCALE, duplocale() shall create a new locale object containing a copy of the global locale determined by the setlocale() function."
Aug 24 at 11:05 history answered Homer512 CC BY-SA 4.0