Share

Improved support for Windows regional settings

The support for Windows regional settings, most notably decimal separators has been improved. The technical terms and Windows APIs involved refer to this aspect as "user locale". The rules governing the locale settings for processes, threads and various run-times is relatively complex. Our goal is to ensure that the users of 3ds Max have a great experience regardless of the Windows regional settings they choose.

3ds Max 2021 is forcing worker threads to use per-thread locales, so they won't interfere with the locale settings of the main thread, which observes the regional settings.

We recommend that plug-ins follow these guidelines:

  • Use string-to-float and float-to-string APIs that take a locale object rather than switching locales. These Windows APIs usually have names that end in "_l". An example is the string-to-float conversion function  _atoflt_l(). The 3ds Max SDK now provides formatted print functions that take a locale object. Examples include:

    size_t BaseTextWriter::Printf_l (const wchar_t* format, const _locale_t theLocale, ...)
    size_t BaseTextWriter::Vprintf_l(const wchar_t* format, const _locale_t theLocale, va_list argList); 
    int CStr::printf_l(const char *format, const _locale_t theLocale, ...); 
    int CStr::vprintf_l(const char *format, const _locale_t theLocale, va_list args); 
    int WStr::printf_l(const wchar_t *format, const _locale_t theLocale, ...); 
    int WStr::vprintf_l(const wchar_t *format, const _locale_t theLocale, va_list args); 
  • Code that formats locale-specific values for UI display, such as floating point numbers, date and time, should use the current Windows locale. For more details see the GetUserLocale() API in the C++ API Reference.

  • Code that writes or reads locale-specific data to and from data files, such as floating point numbers, date and time, etc, should use the C Numeric locale in order to read and write the data in a local independent format such as a minimal ANSI conforming environment for C translation, known as "C" locale. For more details see the GetCNumericLocale() API and class MaxLocaleHandler in the C++ API Reference.

Was this information helpful?