# HG changeset patch # User Sebastien Jodogne # Date 1458565951 -3600 # Node ID 84c7eaeb52442f4dbfe03faf1bb9bb10408b2cd3 # Parent b60f27664b8f5082970c378112d8b6be9cd2d9ad Configuration::GetDefaultEncoding diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/DicomInstanceToStore.cpp --- a/OrthancServer/DicomInstanceToStore.cpp Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/DicomInstanceToStore.cpp Mon Mar 21 14:12:31 2016 +0100 @@ -34,6 +34,7 @@ #include "DicomInstanceToStore.h" #include "FromDcmtkBridge.h" +#include "OrthancInitialization.h" #include "../Core/Logging.h" #include @@ -104,7 +105,8 @@ { summary_.Allocate(); FromDcmtkBridge::Convert(summary_.GetContent(), - *parsed_.GetContent().GetDcmtkObject().getDataset()); + *parsed_.GetContent().GetDcmtkObject().getDataset(), + Configuration::GetDefaultEncoding()); } if (!json_.HasContent()) @@ -114,7 +116,8 @@ *parsed_.GetContent().GetDcmtkObject().getDataset(), DicomToJsonFormat_Full, DicomToJsonFlags_Default, - ORTHANC_MAXIMUM_TAG_LENGTH); + ORTHANC_MAXIMUM_TAG_LENGTH, + Configuration::GetDefaultEncoding()); } } diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/DicomProtocol/DicomUserConnection.cpp --- a/OrthancServer/DicomProtocol/DicomUserConnection.cpp Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/DicomProtocol/DicomUserConnection.cpp Mon Mar 21 14:12:31 2016 +0100 @@ -86,6 +86,7 @@ #include "../../Core/OrthancException.h" #include "../FromDcmtkBridge.h" #include "../ToDcmtkBridge.h" +#include "../OrthancInitialization.h" #include #include @@ -394,7 +395,8 @@ else { DicomMap m; - FromDcmtkBridge::Convert(m, *responseIdentifiers); + FromDcmtkBridge::Convert(m, *responseIdentifiers, + Configuration::GetDefaultEncoding()); if (!m.HasTag(DICOM_TAG_QUERY_RETRIEVE_LEVEL)) { diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/FromDcmtkBridge.cpp --- a/OrthancServer/FromDcmtkBridge.cpp Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/FromDcmtkBridge.cpp Mon Mar 21 14:12:31 2016 +0100 @@ -37,9 +37,9 @@ #endif #include "FromDcmtkBridge.h" -#include "OrthancInitialization.h" #include "../Core/Logging.h" #include "../Core/Toolbox.h" +#include "../Core/Uuid.h" #include "../Core/OrthancException.h" #include @@ -270,11 +270,10 @@ } - Encoding FromDcmtkBridge::DetectEncoding(DcmDataset& dataset) + Encoding FromDcmtkBridge::DetectEncoding(DcmDataset& dataset, + Encoding defaultEncoding) { - // By default, Latin1 encoding is assumed - std::string s = Configuration::GetGlobalStringParameter("DefaultEncoding", "Latin1"); - Encoding encoding = s.empty() ? Encoding_Latin1 : StringToEncoding(s.c_str()); + Encoding encoding = defaultEncoding; OFString tmp; if (dataset.findAndGetOFString(DCM_SpecificCharacterSet, tmp).good()) @@ -305,9 +304,11 @@ } - void FromDcmtkBridge::Convert(DicomMap& target, DcmDataset& dataset) + void FromDcmtkBridge::Convert(DicomMap& target, + DcmDataset& dataset, + Encoding defaultEncoding) { - Encoding encoding = DetectEncoding(dataset); + Encoding encoding = DetectEncoding(dataset, defaultEncoding); target.Clear(); for (unsigned long i = 0; i < dataset.card(); i++) @@ -786,10 +787,11 @@ DcmDataset& dataset, DicomToJsonFormat format, DicomToJsonFlags flags, - unsigned int maxStringLength) + unsigned int maxStringLength, + Encoding defaultEncoding) { target = Json::objectValue; - DatasetToJson(target, dataset, format, flags, maxStringLength, DetectEncoding(dataset)); + DatasetToJson(target, dataset, format, flags, maxStringLength, DetectEncoding(dataset, defaultEncoding)); } diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/FromDcmtkBridge.h --- a/OrthancServer/FromDcmtkBridge.h Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/FromDcmtkBridge.h Mon Mar 21 14:12:31 2016 +0100 @@ -54,9 +54,12 @@ unsigned int minMultiplicity, unsigned int maxMultiplicity); - static Encoding DetectEncoding(DcmDataset& dataset); + static Encoding DetectEncoding(DcmDataset& dataset, + Encoding defaultEncoding); - static void Convert(DicomMap& target, DcmDataset& dataset); + static void Convert(DicomMap& target, + DcmDataset& dataset, + Encoding defaultEncoding); static DicomTag Convert(const DcmTag& tag); @@ -79,7 +82,8 @@ DcmDataset& dataset, DicomToJsonFormat format, DicomToJsonFlags flags, - unsigned int maxStringLength); + unsigned int maxStringLength, + Encoding defaultEncoding); static void ToJson(Json::Value& target, DcmMetaInfo& header, diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/Internals/DicomFrameIndex.cpp --- a/OrthancServer/Internals/DicomFrameIndex.cpp Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/Internals/DicomFrameIndex.cpp Mon Mar 21 14:12:31 2016 +0100 @@ -36,6 +36,7 @@ #include "../../Core/OrthancException.h" #include "../../Core/DicomFormat/DicomImageInformation.h" #include "../FromDcmtkBridge.h" +#include "../OrthancInitialization.h" #include "DicomImageDecoder.h" #include @@ -376,7 +377,8 @@ // Extract information about the image structure DicomMap tags; - FromDcmtkBridge::Convert(tags, dataset); + FromDcmtkBridge::Convert(tags, dataset, + Configuration::GetDefaultEncoding()); DicomImageInformation information(tags); diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/Internals/DicomImageDecoder.cpp --- a/OrthancServer/Internals/DicomImageDecoder.cpp Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/Internals/DicomImageDecoder.cpp Mon Mar 21 14:12:31 2016 +0100 @@ -76,10 +76,6 @@ =========================================================================*/ - -#include "../PrecompiledHeadersServer.h" -#include "DicomImageDecoder.h" - #include "../../Core/Logging.h" #include "../../Core/OrthancException.h" #include "../../Core/Images/Image.h" @@ -90,6 +86,7 @@ #include "../ToDcmtkBridge.h" #include "../FromDcmtkBridge.h" #include "../ParsedDicomFile.h" +#include "../OrthancInitialization.h" #include @@ -245,7 +242,8 @@ // See also: http://support.dcmtk.org/wiki/dcmtk/howto/accessing-compressed-data DicomMap m; - FromDcmtkBridge::Convert(m, dataset); + FromDcmtkBridge::Convert(m, dataset, + Configuration::GetDefaultEncoding()); /** * Create an accessor to the raw values of the DICOM image. @@ -317,7 +315,8 @@ bool ignorePhotometricInterpretation) { DicomMap m; - FromDcmtkBridge::Convert(m, dataset); + FromDcmtkBridge::Convert(m, dataset, + Configuration::GetDefaultEncoding()); DicomImageInformation info(m); PixelFormat format; diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/Internals/FindScp.cpp --- a/OrthancServer/Internals/FindScp.cpp Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/Internals/FindScp.cpp Mon Mar 21 14:12:31 2016 +0100 @@ -86,6 +86,7 @@ #include "../ToDcmtkBridge.h" #include "../../Core/Logging.h" #include "../../Core/OrthancException.h" +#include "../OrthancInitialization.h" #include @@ -170,7 +171,8 @@ } DicomMap input; - FromDcmtkBridge::Convert(input, *requestIdentifiers); + FromDcmtkBridge::Convert(input, *requestIdentifiers, + Configuration::GetDefaultEncoding()); data.findHandler_->Handle(data.answers_, input, sequencesToReturn, *data.remoteIp_, *data.remoteAet_, *data.calledAet_); diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/Internals/MoveScp.cpp --- a/OrthancServer/Internals/MoveScp.cpp Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/Internals/MoveScp.cpp Mon Mar 21 14:12:31 2016 +0100 @@ -86,6 +86,7 @@ #include "../FromDcmtkBridge.h" #include "../ToDcmtkBridge.h" +#include "../OrthancInitialization.h" #include "../../Core/Logging.h" #include "../../Core/OrthancException.h" @@ -129,7 +130,8 @@ if (data.lastRequest_ == NULL) { DicomMap input; - FromDcmtkBridge::Convert(input, *requestIdentifiers); + FromDcmtkBridge::Convert(input, *requestIdentifiers, + Configuration::GetDefaultEncoding()); try { diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/Internals/StoreScp.cpp --- a/OrthancServer/Internals/StoreScp.cpp Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/Internals/StoreScp.cpp Mon Mar 21 14:12:31 2016 +0100 @@ -85,6 +85,7 @@ #include "../FromDcmtkBridge.h" #include "../ServerToolbox.h" #include "../ToDcmtkBridge.h" +#include "../OrthancInitialization.h" #include "../../Core/OrthancException.h" #include "../../Core/Logging.h" @@ -167,11 +168,13 @@ try { - FromDcmtkBridge::Convert(summary, **imageDataSet); + FromDcmtkBridge::Convert(summary, **imageDataSet, + Configuration::GetDefaultEncoding()); FromDcmtkBridge::ToJson(dicomJson, **imageDataSet, DicomToJsonFormat_Full, DicomToJsonFlags_Default, - ORTHANC_MAXIMUM_TAG_LENGTH); + ORTHANC_MAXIMUM_TAG_LENGTH, + Configuration::GetDefaultEncoding()); if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, **imageDataSet)) { diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/OrthancInitialization.cpp --- a/OrthancServer/OrthancInitialization.cpp Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/OrthancInitialization.cpp Mon Mar 21 14:12:31 2016 +0100 @@ -1031,4 +1031,13 @@ { return fontRegistry_; } + + + Encoding Configuration::GetDefaultEncoding() + { + std::string s = GetGlobalStringParameter("DefaultEncoding", "Latin1"); + + // By default, Latin1 encoding is assumed + return s.empty() ? Encoding_Latin1 : StringToEncoding(s.c_str()); + } } diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/OrthancInitialization.h --- a/OrthancServer/OrthancInitialization.h Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/OrthancInitialization.h Mon Mar 21 14:12:31 2016 +0100 @@ -115,5 +115,7 @@ static void FormatConfiguration(std::string& result); static const FontRegistry& GetFontRegistry(); + + static Encoding GetDefaultEncoding(); }; } diff -r b60f27664b8f -r 84c7eaeb5244 OrthancServer/ParsedDicomFile.cpp --- a/OrthancServer/ParsedDicomFile.cpp Mon Mar 21 13:31:56 2016 +0100 +++ b/OrthancServer/ParsedDicomFile.cpp Mon Mar 21 14:12:31 2016 +0100 @@ -1059,7 +1059,8 @@ Encoding ParsedDicomFile::GetEncoding() const { - return FromDcmtkBridge::DetectEncoding(*pimpl_->file_->getDataset()); + return FromDcmtkBridge::DetectEncoding(*pimpl_->file_->getDataset(), + Configuration::GetDefaultEncoding()); } @@ -1081,7 +1082,9 @@ DicomToJsonFlags flags, unsigned int maxStringLength) { - FromDcmtkBridge::ToJson(target, *pimpl_->file_->getDataset(), format, flags, maxStringLength); + FromDcmtkBridge::ToJson(target, *pimpl_->file_->getDataset(), + format, flags, maxStringLength, + Configuration::GetDefaultEncoding()); } @@ -1184,7 +1187,8 @@ void ParsedDicomFile::Convert(DicomMap& tags) { - FromDcmtkBridge::Convert(tags, *pimpl_->file_->getDataset()); + FromDcmtkBridge::Convert(tags, *pimpl_->file_->getDataset(), + Configuration::GetDefaultEncoding()); }