aboutsummaryrefslogtreecommitdiffstats
path: root/examples/example3.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2014-01-15 23:27:51 +0000
committerVincent Richard <[email protected]>2014-01-15 23:27:51 +0000
commitef892af6556724b6d04dfb1767dce132f9d97257 (patch)
treedee732540e681ad58c4f6835c2d960238bf20b26 /examples/example3.cpp
parentAvoid calling charset::convert() if no conversion is needed. (diff)
downloadvmime-ef892af6556724b6d04dfb1767dce132f9d97257.tar.gz
vmime-ef892af6556724b6d04dfb1767dce132f9d97257.zip
Do not make calls to setlocale() in a library. Use default user locale in tests and examples.
Diffstat (limited to 'examples/example3.cpp')
-rw-r--r--examples/example3.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/examples/example3.cpp b/examples/example3.cpp
index 56b3c7e7..a472e05c 100644
--- a/examples/example3.cpp
+++ b/examples/example3.cpp
@@ -32,6 +32,8 @@
//
#include <iostream>
+#include <locale>
+#include <clocale>
#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<vmime::platforms::posix::posixHandler>();
+ // 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
{