diff --git a/cli/pict.cpp b/cli/pict.cpp index 2f759f3bdde8f48e3ae270989df396e27b31e6cb..05736528e5c041e4e9d18344938a0cdd93623470 100644 --- a/cli/pict.cpp +++ b/cli/pict.cpp @@ -6,6 +6,7 @@ #include <ctime> #include <cstring> #include <locale> +#include <stdexcept> using namespace std; #include "cmdline.h" @@ -129,8 +130,18 @@ int main IN char* args[] ) { - // Use UTF-8 for multi-byte character I/O everywhare - std::locale::global(std::locale("C.UTF-8")); + // Use "C.UTF-8" locale for multi-byte character I/O everywhare + // If "C.UTF-8" locale is not supported, use classic "C" locale as fallback. + std::locale loc; + try + { + loc = std::locale("C.UTF-8"); + } + catch ( std::runtime_error ) + { + loc = std::locale::classic(); + } + std::locale::global(loc); // convert all args to wchar_t's wchar_t** wargs = new wchar_t*[ argc ];