Alain Bench <[EMAIL PROTECTED]> writes:

>> Would "" be appropriate in that case?
>
>     Yes: setlocale(LC_ALL, "") should always select the ANSI charset,
> suitable for graphic mode apps. Finally GetACP() is not needed, as ""
> does implicitly the same.

Then the code could look like this:

#ifdef WINDOWS
  if (GetConsoleOutputCP () != 0)
    {
      char console_code_page[32];
      snprintf (console_code_page, sizeof console_code_page,
                ".%u", GetConsoleOutputCP ());
      if (!setlocale (LC_ALL, console_code_page))
        setlocale (LC_ALL, ".OCP");
    }
  else
#endif
    setlocale (LC_ALL, "");

Reply via email to