aboutsummaryrefslogtreecommitdiffstats
path: root/examples/example6.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/example6.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/example6.cpp')
-rw-r--r--examples/example6.cpp14
1 files changed, 12 insertions, 2 deletions
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 <sstream>
#include <vector>
#include <map>
+#include <locale>
+#include <clocale>
#include "vmime/vmime.hpp"
#include "vmime/platforms/posix/posixHandler.hpp"
@@ -916,8 +918,16 @@ static bool menu()
int main()
{
- // 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, "");
+ }
for (bool quit = false ; !quit ; )
{