diff options
Diffstat (limited to 'examples/example2.cpp')
-rw-r--r-- | examples/example2.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/examples/example2.cpp b/examples/example2.cpp index 56f01b03..67b8d844 100644 --- a/examples/example2.cpp +++ b/examples/example2.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 { @@ -71,7 +81,7 @@ int main() // Adding an attachment vmime::shared_ptr <vmime::fileAttachment> a = vmime::make_shared <vmime::fileAttachment> ( - "./example2.cpp", // full path to file + __FILE__, // full path to file vmime::mediaType("application/octet-stream"), // content type vmime::text("My first attachment") // description ); |