comparison OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 1557:ad1e127b4ed5

fix in encodings
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 Aug 2015 17:29:42 +0200
parents d6a93e12b1c1
children 124de28b32ed
comparison
equal deleted inserted replaced
1556:b8dc2f855a83 1557:ad1e127b4ed5
35 35
36 #include "../../Core/Logging.h" 36 #include "../../Core/Logging.h"
37 #include "../../Core/Uuid.h" 37 #include "../../Core/Uuid.h"
38 #include "../FromDcmtkBridge.h" 38 #include "../FromDcmtkBridge.h"
39 #include "../ServerContext.h" 39 #include "../ServerContext.h"
40 #include "../OrthancInitialization.h"
40 41
41 namespace Orthanc 42 namespace Orthanc
42 { 43 {
43 // Modification of DICOM instances ------------------------------------------ 44 // Modification of DICOM instances ------------------------------------------
44 45
473 if (!request.isMember("Tags") || 474 if (!request.isMember("Tags") ||
474 request["Tags"].type() != Json::objectValue) 475 request["Tags"].type() != Json::objectValue)
475 { 476 {
476 return false; 477 return false;
477 } 478 }
479
480 std::string tmp;
481 if (request["Tags"].isMember("SpecificCharacterSet"))
482 {
483 tmp = request["Tags"]["SpecificCharacterSet"].asString();
484 }
485 else
486 {
487 tmp = Configuration::GetGlobalStringParameter("DefaultEncoding", "Latin1");
488 }
489
490 Encoding encoding = StringToEncoding(tmp.c_str());
491 dicom.SetEncoding(encoding);
478 492
479 ResourceType parentType = ResourceType_Instance; 493 ResourceType parentType = ResourceType_Instance;
480 494
481 if (request.isMember("Parent")) 495 if (request.isMember("Parent"))
482 { 496 {
547 { 561 {
548 dicom.Replace(*it, ""); 562 dicom.Replace(*it, "");
549 } 563 }
550 else if (tag["Type"] == "String") 564 else if (tag["Type"] == "String")
551 { 565 {
552 dicom.Replace(*it, tag["Value"].asString()); 566 std::string value = tag["Value"].asString();
567 dicom.Replace(*it, Toolbox::ConvertFromUtf8(value, encoding));
553 } 568 }
554 } 569 }
555 } 570 }
556 } 571 }
557 572
607 LOG(ERROR) << "Use \"Content\" to inject an image into a new DICOM instance"; 622 LOG(ERROR) << "Use \"Content\" to inject an image into a new DICOM instance";
608 return false; 623 return false;
609 } 624 }
610 else 625 else
611 { 626 {
612 dicom.Replace(tag, value); 627 dicom.Replace(tag, Toolbox::ConvertFromUtf8(value, encoding));
613 } 628 }
614 } 629 }
615 630
616 631
617 // Inject the content (either an image, or a PDF file) 632 // Inject the content (either an image, or a PDF file)