From ef892af6556724b6d04dfb1767dce132f9d97257 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 16 Jan 2014 00:27:51 +0100 Subject: Do not make calls to setlocale() in a library. Use default user locale in tests and examples. --- examples/example6.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'examples/example6.cpp') diff --git a/examples/example6.cpp b/examples/example6.cpp index 30767c3e..54f1364b 100644 --- a/examples/example6.cpp +++ b/examples/example6.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include "vmime/vmime.hpp" #include "vmime/platforms/posix/posixHandler.hpp" @@ -916,8 +918,16 @@ static bool menu() int main() { - // VMime initialization - vmime::platform::setHandler(); + // Set the global C and C++ locale to the user-configured locale. + // The locale should use UTF-8 encoding for these tests to run successfully. + try + { + std::locale::global(std::locale("")); + } + catch (std::exception &) + { + std::setlocale(LC_ALL, ""); + } for (bool quit = false ; !quit ; ) { -- cgit v1.2.3