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/example1.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'examples/example1.cpp') diff --git a/examples/example1.cpp b/examples/example1.cpp index 9948d606..b80fe636 100644 --- a/examples/example1.cpp +++ b/examples/example1.cpp @@ -32,6 +32,8 @@ // #include +#include +#include #include "vmime/vmime.hpp" #include "vmime/platforms/posix/posixHandler.hpp" @@ -41,8 +43,16 @@ int main() { std::cout << std::endl; - // 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, ""); + } try { -- cgit v1.2.3