comparison Core/Toolbox.cpp @ 952:98d6ba37c7dc dicom-rt

integration mainline -> dicom-rt
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Jun 2014 15:33:02 +0200
parents a6fda0806382 8811abd6aec9
children
comparison
equal deleted inserted replaced
951:a6fda0806382 952:98d6ba37c7dc
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);