Mercurial > hg > orthanc
comparison Core/Toolbox.cpp @ 955:743a75b14bef plugins
merge mainline -> plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 25 Jun 2014 15:37:48 +0200 |
parents | 3fb427ac3f53 8811abd6aec9 |
children | 509e146c3cb3 |
comparison
equal
deleted
inserted
replaced
944:c068671d12a9 | 955:743a75b14bef |
---|---|
64 #error Since version 0.7.6, Orthanc entirely relies on boost::locale | 64 #error Since version 0.7.6, Orthanc entirely relies on boost::locale |
65 #endif | 65 #endif |
66 | 66 |
67 #include <boost/locale.hpp> | 67 #include <boost/locale.hpp> |
68 | 68 |
69 #include "../Resources/md5/md5.h" | 69 #include "../Resources/ThirdParty/md5/md5.h" |
70 #include "../Resources/base64/base64.h" | 70 #include "../Resources/ThirdParty/base64/base64.h" |
71 | 71 |
72 | 72 |
73 #ifdef _MSC_VER | 73 #ifdef _MSC_VER |
74 // Patch for the missing "_strtoll" symbol when compiling with Visual Studio | 74 // Patch for the missing "_strtoll" symbol when compiling with Visual Studio |
75 extern "C" | 75 extern "C" |
493 return p.parent_path().string(); | 493 return p.parent_path().string(); |
494 } | 494 } |
495 | 495 |
496 | 496 |
497 std::string Toolbox::ConvertToUtf8(const std::string& source, | 497 std::string Toolbox::ConvertToUtf8(const std::string& source, |
498 const char* fromEncoding) | 498 const Encoding sourceEncoding) |
499 { | 499 { |
500 const char* encoding; | |
501 | |
502 switch (sourceEncoding) | |
503 { | |
504 case Encoding_Utf8: | |
505 // Already in UTF-8: No conversion is required | |
506 return source; | |
507 | |
508 case Encoding_Latin1: | |
509 encoding = "ISO-8859-1"; | |
510 break; | |
511 | |
512 default: | |
513 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
514 } | |
515 | |
500 try | 516 try |
501 { | 517 { |
502 return boost::locale::conv::to_utf<char>(source, fromEncoding); | 518 return boost::locale::conv::to_utf<char>(source, encoding); |
503 } | 519 } |
504 catch (std::runtime_error&) | 520 catch (std::runtime_error&) |
505 { | 521 { |
506 // Bad input string or bad encoding | 522 // Bad input string or bad encoding |
507 return ConvertToAscii(source); | 523 return ConvertToAscii(source); |