changeset 5291:800261398381

Made Orthanc more resilient to common spelling errors in SpecificCharacterSet
author Alain Mazy <am@osimis.io>
date Tue, 09 May 2023 17:48:33 +0200
parents 0035d4318594
children 143b45791233
files NEWS OrthancFramework/Sources/Enumerations.cpp OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp
diffstat 3 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri May 05 09:03:04 2023 +0200
+++ b/NEWS	Tue May 09 17:48:33 2023 +0200
@@ -6,6 +6,7 @@
 
 * Fix decoding of YBR_FULL RLE images for which the "Planar Configuration" 
   tag (0028,0006) equals 1
+* Made Orthanc more resilient to common spelling errors in SpecificCharacterSet
 * Upgraded dependencies for static builds:
   - boost 1.82.0
 
--- a/OrthancFramework/Sources/Enumerations.cpp	Fri May 05 09:03:04 2023 +0200
+++ b/OrthancFramework/Sources/Enumerations.cpp	Tue May 09 17:48:33 2023 +0200
@@ -31,6 +31,7 @@
 #include <boost/thread/mutex.hpp>
 #include <string.h>
 #include <cassert>
+#include <boost/algorithm/string/replace.hpp>
 
 namespace Orthanc
 {
@@ -1933,6 +1934,11 @@
     std::string s = Toolbox::StripSpaces(specificCharacterSet);
     Toolbox::ToUpperCase(s);
 
+    // handle common spelling mistakes
+    boost::replace_all(s, "ISO_IR_", "ISO_IR ");
+    boost::replace_all(s, "ISO_2022_IR_", "ISO 2022 IR ");
+
+
     // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#sect_C.12.1.1.2
     // https://github.com/dcm4che/dcm4che/blob/master/dcm4che-core/src/main/java/org/dcm4che3/data/SpecificCharacterSet.java
     if (s == "ISO_IR 6" ||
--- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp	Fri May 05 09:03:04 2023 +0200
+++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp	Tue May 09 17:48:33 2023 +0200
@@ -314,6 +314,10 @@
   ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 192"));  ASSERT_EQ(Encoding_Utf8, e);
   ASSERT_TRUE(GetDicomEncoding(e, "GB18030"));     ASSERT_EQ(Encoding_Chinese, e);
   ASSERT_TRUE(GetDicomEncoding(e, "GBK"));         ASSERT_EQ(Encoding_Chinese, e);
+
+  // common spelling mistakes
+  ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR_100"));  ASSERT_EQ(Encoding_Latin1, e);
+  ASSERT_TRUE(GetDicomEncoding(e, "ISO_2022_IR_6"));  ASSERT_EQ(Encoding_Ascii, e);
 }