changeset 3228:4b9cfd92d1ae

preparing for libicu
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 14 Feb 2019 19:41:09 +0100
parents 53bb1f4b3844
children 77e8378f0323
files Resources/CMake/BoostConfiguration.cmake Resources/CMake/LibIconvConfiguration.cmake Resources/CMake/LibIcuConfiguration.cmake Resources/CMake/OrthancFrameworkConfiguration.cmake Resources/CMake/OrthancFrameworkParameters.cmake UnitTestsSources/FromDcmtkTests.cpp
diffstat 6 files changed, 229 insertions(+), 112 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/BoostConfiguration.cmake	Thu Feb 14 16:22:52 2019 +0100
+++ b/Resources/CMake/BoostConfiguration.cmake	Thu Feb 14 19:41:09 2019 +0100
@@ -246,6 +246,11 @@
 
     if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR
         CMAKE_SYSTEM_VERSION STREQUAL "LinuxStandardBase")
+      add_definitions(
+        -DBOOST_LOCALE_NO_WINAPI_BACKEND=1
+        -DBOOST_LOCALE_NO_POSIX_BACKEND=1
+        )
+      
       list(APPEND BOOST_SOURCES
         ${BOOST_SOURCES_DIR}/libs/locale/src/std/codecvt.cpp
         ${BOOST_SOURCES_DIR}/libs/locale/src/std/collate.cpp
@@ -254,12 +259,14 @@
         ${BOOST_SOURCES_DIR}/libs/locale/src/std/std_backend.cpp
         )
 
-      add_definitions(
-        -DBOOST_LOCALE_WITH_ICONV=1
-        -DBOOST_LOCALE_NO_WINAPI_BACKEND=1
-        -DBOOST_LOCALE_NO_POSIX_BACKEND=1
-        )
-      
+      if (BOOST_LOCALE_BACKEND STREQUAL "iconv")
+        add_definitions(-DBOOST_LOCALE_WITH_ICONV=1)
+      elseif (BOOST_LOCALE_BACKEND STREQUAL "icu")
+        add_definitions(-DBOOST_LOCALE_WITH_ICU=1)
+      else()
+        message(FATAL_ERROR "Unsupported value for BOOST_LOCALE_BACKEND: ${BOOST_LOCALE_BACKEND}")
+      endif()
+
     elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
             CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
             CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
@@ -268,6 +275,11 @@
             CMAKE_SYSTEM_NAME STREQUAL "NaCl32" OR
             CMAKE_SYSTEM_NAME STREQUAL "NaCl64" OR
             CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # For WebAssembly or asm.js
+      add_definitions(
+        -DBOOST_LOCALE_NO_WINAPI_BACKEND=1
+        -DBOOST_LOCALE_NO_STD_BACKEND=1
+        )
+      
       list(APPEND BOOST_SOURCES
         ${BOOST_SOURCES_DIR}/libs/locale/src/posix/codecvt.cpp
         ${BOOST_SOURCES_DIR}/libs/locale/src/posix/collate.cpp
@@ -276,13 +288,34 @@
         ${BOOST_SOURCES_DIR}/libs/locale/src/posix/posix_backend.cpp
         )
 
+      if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR
+          BOOST_LOCALE_BACKEND STREQUAL "iconv")
+        # In WebAssembly or asm.js, we rely on the version of iconv
+        # that is shipped with the stdlib
+        add_definitions(-DBOOST_LOCALE_WITH_ICONV=1)
+      elseif (BOOST_LOCALE_BACKEND STREQUAL "icu")
+        add_definitions(-DBOOST_LOCALE_WITH_ICU=1)
+        list(APPEND BOOST_SOURCES
+           ${BOOST_SOURCES_DIR}/libs/locale/src/icu/boundary.cpp
+           ${BOOST_SOURCES_DIR}/libs/locale/src/icu/codecvt.cpp
+           ${BOOST_SOURCES_DIR}/libs/locale/src/icu/collator.cpp
+           ${BOOST_SOURCES_DIR}/libs/locale/src/icu/conversion.cpp
+           ${BOOST_SOURCES_DIR}/libs/locale/src/icu/date_time.cpp
+           ${BOOST_SOURCES_DIR}/libs/locale/src/icu/formatter.cpp   
+           ${BOOST_SOURCES_DIR}/libs/locale/src/icu/icu_backend.cpp
+           ${BOOST_SOURCES_DIR}/libs/locale/src/icu/numeric.cpp
+           ${BOOST_SOURCES_DIR}/libs/locale/src/icu/time_zone.cpp
+          )        
+      else()
+        message(FATAL_ERROR "Unsupported value for BOOST_LOCALE_BACKEND: ${BOOST_LOCALE_BACKEND}")
+      endif()
+
+    elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
       add_definitions(
-        -DBOOST_LOCALE_WITH_ICONV=1
-        -DBOOST_LOCALE_NO_WINAPI_BACKEND=1
+        -DBOOST_LOCALE_NO_POSIX_BACKEND=1
         -DBOOST_LOCALE_NO_STD_BACKEND=1
         )
-      
-    elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
+
       list(APPEND BOOST_SOURCES
         ${BOOST_SOURCES_DIR}/libs/locale/src/win32/collate.cpp
         ${BOOST_SOURCES_DIR}/libs/locale/src/win32/converter.cpp
@@ -291,19 +324,18 @@
         ${BOOST_SOURCES_DIR}/libs/locale/src/win32/win_backend.cpp
         )
 
-      add_definitions(
-        -DBOOST_LOCALE_NO_POSIX_BACKEND=1
-        -DBOOST_LOCALE_NO_STD_BACKEND=1
-        )
-
       # Starting with release 0.8.2, Orthanc statically links against
       # libiconv, even on Windows. Indeed, the "WCONV" library of
       # Windows XP seems not to support properly several codepages
       # (notably "Latin3", "Hebrew", and "Arabic"). Set
-      # "USE_BOOST_ICONV" to "OFF" to use WCONV anyway.
+      # "BOOST_LOCALE_BACKEND" to "wconv" to use WCONV anyway.
 
-      if (USE_BOOST_ICONV)
+      if (BOOST_LOCALE_BACKEND STREQUAL "iconv")
         add_definitions(-DBOOST_LOCALE_WITH_ICONV=1)
+      elseif (BOOST_LOCALE_BACKEND STREQUAL "icu")
+        add_definitions(-DBOOST_LOCALE_WITH_ICU=1)
+      elseif (BOOST_LOCALE_BACKEND STREQUAL "wconv")
+        message("Using Window's wconv")
       else()
         add_definitions(-DBOOST_LOCALE_WITH_WCONV=1)
       endif()
--- a/Resources/CMake/LibIconvConfiguration.cmake	Thu Feb 14 16:22:52 2019 +0100
+++ b/Resources/CMake/LibIconvConfiguration.cmake	Thu Feb 14 19:41:09 2019 +0100
@@ -1,98 +1,89 @@
-if (NOT ENABLE_LOCALE)
-  message("Support for locales is disabled")
-
-elseif (NOT USE_BOOST_ICONV)
-  message("Not using libiconv")
+message("Using libiconv")
 
-else()
-  message("Using libiconv")
+if (STATIC_BUILD OR NOT USE_SYSTEM_LIBICONV)
+  set(LIBICONV_SOURCES_DIR ${CMAKE_BINARY_DIR}/libiconv-1.15)
+  set(LIBICONV_URL "http://orthanc.osimis.io/ThirdPartyDownloads/libiconv-1.15.tar.gz")
+  set(LIBICONV_MD5 "ace8b5f2db42f7b3b3057585e80d9808")
 
-  if (STATIC_BUILD OR NOT USE_SYSTEM_LIBICONV)
-    set(LIBICONV_SOURCES_DIR ${CMAKE_BINARY_DIR}/libiconv-1.15)
-    set(LIBICONV_URL "http://orthanc.osimis.io/ThirdPartyDownloads/libiconv-1.15.tar.gz")
-    set(LIBICONV_MD5 "ace8b5f2db42f7b3b3057585e80d9808")
-
-    DownloadPackage(${LIBICONV_MD5} ${LIBICONV_URL} "${LIBICONV_SOURCES_DIR}")
+  DownloadPackage(${LIBICONV_MD5} ${LIBICONV_URL} "${LIBICONV_SOURCES_DIR}")
 
-    # Disable the support of libiconv that is shipped by default with
-    # the C standard library on Linux. Setting this macro redirects
-    # calls from "iconv*()" to "libiconv*()" by defining macros in the
-    # C headers of "libiconv-1.15".
-    add_definitions(-DLIBICONV_PLUG=1)
+  # Disable the support of libiconv that is shipped by default with
+  # the C standard library on Linux. Setting this macro redirects
+  # calls from "iconv*()" to "libiconv*()" by defining macros in the
+  # C headers of "libiconv-1.15".
+  add_definitions(-DLIBICONV_PLUG=1)
 
-    # https://groups.google.com/d/msg/android-ndk/AS1nkxnk6m4/EQm09hD1tigJ
-    add_definitions(
-      -DBUILDING_LIBICONV=1
-      -DIN_LIBRARY=1
-      -DLIBDIR=""
-      -DICONV_CONST=
-      )
+  # https://groups.google.com/d/msg/android-ndk/AS1nkxnk6m4/EQm09hD1tigJ
+  add_definitions(
+    -DBUILDING_LIBICONV=1
+    -DIN_LIBRARY=1
+    -DLIBDIR=""
+    -DICONV_CONST=
+    )
 
-    configure_file(
-      ${LIBICONV_SOURCES_DIR}/srclib/localcharset.h
-      ${LIBICONV_SOURCES_DIR}/include
-      COPYONLY)
+  configure_file(
+    ${LIBICONV_SOURCES_DIR}/srclib/localcharset.h
+    ${LIBICONV_SOURCES_DIR}/include
+    COPYONLY)
 
-    set(HAVE_VISIBILITY 0)
-    set(ICONV_CONST ${ICONV_CONST})
-    set(USE_MBSTATE_T 1)
-    set(BROKEN_WCHAR_H 0)
-    set(EILSEQ)
-    set(HAVE_WCHAR_T 1)
-    configure_file(
-      ${LIBICONV_SOURCES_DIR}/include/iconv.h.build.in
-      ${LIBICONV_SOURCES_DIR}/include/iconv.h
-      )
-    unset(HAVE_VISIBILITY)
-    unset(ICONV_CONST)
-    unset(USE_MBSTATE_T)
-    unset(BROKEN_WCHAR_H)
-    unset(EILSEQ)
-    unset(HAVE_WCHAR_T)
+  set(HAVE_VISIBILITY 0)
+  set(ICONV_CONST ${ICONV_CONST})
+  set(USE_MBSTATE_T 1)
+  set(BROKEN_WCHAR_H 0)
+  set(EILSEQ)
+  set(HAVE_WCHAR_T 1)
+  configure_file(
+    ${LIBICONV_SOURCES_DIR}/include/iconv.h.build.in
+    ${LIBICONV_SOURCES_DIR}/include/iconv.h
+    )
+  unset(HAVE_VISIBILITY)
+  unset(ICONV_CONST)
+  unset(USE_MBSTATE_T)
+  unset(BROKEN_WCHAR_H)
+  unset(EILSEQ)
+  unset(HAVE_WCHAR_T)
 
-    if (NOT EXISTS ${LIBICONV_SOURCES_DIR}/include/config.h)
-      # Create an empty "config.h" for libiconv
-      file(WRITE ${LIBICONV_SOURCES_DIR}/include/config.h "")
-    endif()
+  if (NOT EXISTS ${LIBICONV_SOURCES_DIR}/include/config.h)
+    # Create an empty "config.h" for libiconv
+    file(WRITE ${LIBICONV_SOURCES_DIR}/include/config.h "")
+  endif()
 
-    include_directories(
-      ${LIBICONV_SOURCES_DIR}/include
-      )
+  include_directories(
+    ${LIBICONV_SOURCES_DIR}/include
+    )
 
-    set(LIBICONV_SOURCES
-      ${LIBICONV_SOURCES_DIR}/lib/iconv.c  
-      ${LIBICONV_SOURCES_DIR}/lib/relocatable.c
-      ${LIBICONV_SOURCES_DIR}/libcharset/lib/localcharset.c  
-      ${LIBICONV_SOURCES_DIR}/libcharset/lib/relocatable.c
-      )
+  set(LIBICONV_SOURCES
+    ${LIBICONV_SOURCES_DIR}/lib/iconv.c  
+    ${LIBICONV_SOURCES_DIR}/lib/relocatable.c
+    ${LIBICONV_SOURCES_DIR}/libcharset/lib/localcharset.c  
+    ${LIBICONV_SOURCES_DIR}/libcharset/lib/relocatable.c
+    )
 
-    source_group(ThirdParty\\libiconv REGULAR_EXPRESSION ${LIBICONV_SOURCES_DIR}/.*)
+  source_group(ThirdParty\\libiconv REGULAR_EXPRESSION ${LIBICONV_SOURCES_DIR}/.*)
 
-    if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
-      add_definitions(-DHAVE_WORKING_O_NOFOLLOW=0)
-    else()
-      add_definitions(-DHAVE_WORKING_O_NOFOLLOW=1)
-    endif()
+  if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
+    add_definitions(-DHAVE_WORKING_O_NOFOLLOW=0)
+  else()
+    add_definitions(-DHAVE_WORKING_O_NOFOLLOW=1)
+  endif()
 
-  else() 
-    CHECK_INCLUDE_FILE_CXX(iconv.h HAVE_ICONV_H)
-    if (NOT HAVE_ICONV_H)
-      message(FATAL_ERROR "Please install the libiconv-dev package")
-    endif()
+else() 
+  CHECK_INCLUDE_FILE_CXX(iconv.h HAVE_ICONV_H)
+  if (NOT HAVE_ICONV_H)
+    message(FATAL_ERROR "Please install the libiconv-dev package")
+  endif()
 
-    # Check whether the support for libiconv is bundled within the
-    # standard C library
-    CHECK_FUNCTION_EXISTS(iconv_open HAVE_ICONV_LIB)
-    if (NOT HAVE_ICONV_LIB)
-      # No builtin support for libiconv, try and find an external library.
-      # Open question: Does this make sense on any platform?
-      CHECK_LIBRARY_EXISTS(iconv iconv_open "" HAVE_ICONV_LIB_2)
-      if (NOT HAVE_ICONV_LIB_2)
-        message(FATAL_ERROR "Please install the libiconv-dev package")
-      else()
-        link_libraries(iconv)
-      endif()
+  # Check whether the support for libiconv is bundled within the
+  # standard C library
+  CHECK_FUNCTION_EXISTS(iconv_open HAVE_ICONV_LIB)
+  if (NOT HAVE_ICONV_LIB)
+    # No builtin support for libiconv, try and find an external library.
+    # Open question: Does this make sense on any platform?
+    CHECK_LIBRARY_EXISTS(iconv iconv_open "" HAVE_ICONV_LIB_2)
+    if (NOT HAVE_ICONV_LIB_2)
+      message(FATAL_ERROR "Please install the libiconv-dev package")
+    else()
+      link_libraries(iconv)
     endif()
-
   endif()
 endif()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/CMake/LibIcuConfiguration.cmake	Thu Feb 14 19:41:09 2019 +0100
@@ -0,0 +1,83 @@
+message("Using libicu")
+
+if (STATIC_BUILD OR NOT USE_SYSTEM_LIBICU)
+  # set(LIBICU_SOURCES_DIR ${CMAKE_BINARY_DIR}/libicu-1.15)
+  # set(LIBICU_URL "http://orthanc.osimis.io/ThirdPartyDownloads/libicu-1.15.tar.gz")
+  # set(LIBICU_MD5 "ace8b5f2db42f7b3b3057585e80d9808")
+
+  # DownloadPackage(${LIBICU_MD5} ${LIBICU_URL} "${LIBICU_SOURCES_DIR}")
+
+  # # Disable the support of libicu that is shipped by default with
+  # # the C standard library on Linux. Setting this macro redirects
+  # # calls from "icu*()" to "libicu*()" by defining macros in the
+  # # C headers of "libicu-1.15".
+  # add_definitions(-DLIBICU_PLUG=1)
+
+  # # https://groups.google.com/d/msg/android-ndk/AS1nkxnk6m4/EQm09hD1tigJ
+  # add_definitions(
+  #   -DBUILDING_LIBICU=1
+  #   -DIN_LIBRARY=1
+  #   -DLIBDIR=""
+  #   -DICU_CONST=
+  #   )
+
+  # configure_file(
+  #   ${LIBICU_SOURCES_DIR}/srclib/localcharset.h
+  #   ${LIBICU_SOURCES_DIR}/include
+  #   COPYONLY)
+
+  # set(HAVE_VISIBILITY 0)
+  # set(ICU_CONST ${ICU_CONST})
+  # set(USE_MBSTATE_T 1)
+  # set(BROKEN_WCHAR_H 0)
+  # set(EILSEQ)
+  # set(HAVE_WCHAR_T 1)
+  # configure_file(
+  #   ${LIBICU_SOURCES_DIR}/include/icu.h.build.in
+  #   ${LIBICU_SOURCES_DIR}/include/icu.h
+  #   )
+  # unset(HAVE_VISIBILITY)
+  # unset(ICU_CONST)
+  # unset(USE_MBSTATE_T)
+  # unset(BROKEN_WCHAR_H)
+  # unset(EILSEQ)
+  # unset(HAVE_WCHAR_T)
+
+  # if (NOT EXISTS ${LIBICU_SOURCES_DIR}/include/config.h)
+  #   # Create an empty "config.h" for libicu
+  #   file(WRITE ${LIBICU_SOURCES_DIR}/include/config.h "")
+  # endif()
+
+  # include_directories(
+  #   ${LIBICU_SOURCES_DIR}/include
+  #   )
+
+  # set(LIBICU_SOURCES
+  #   ${LIBICU_SOURCES_DIR}/lib/icu.c  
+  #   ${LIBICU_SOURCES_DIR}/lib/relocatable.c
+  #   ${LIBICU_SOURCES_DIR}/libcharset/lib/localcharset.c  
+  #   ${LIBICU_SOURCES_DIR}/libcharset/lib/relocatable.c
+  #   )
+
+  # source_group(ThirdParty\\libicu REGULAR_EXPRESSION ${LIBICU_SOURCES_DIR}/.*)
+
+  # if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
+  #   add_definitions(-DHAVE_WORKING_O_NOFOLLOW=0)
+  # else()
+  #   add_definitions(-DHAVE_WORKING_O_NOFOLLOW=1)
+  # endif()
+
+else() 
+  CHECK_INCLUDE_FILE_CXX(unicode/uvernum.h HAVE_ICU_H)
+  if (NOT HAVE_ICU_H)
+    message(FATAL_ERROR "Please install the libicu-dev package")
+  endif()
+
+  CHECK_LIBRARY_EXISTS(icuuc udata_close "" HAVE_ICU_LIB)
+  if (NOT HAVE_ICU_LIB)
+    #message(FATAL_ERROR "Please install the libicu-dev package")
+    link_libraries(icuuc)
+  else()
+    link_libraries(icuuc)
+  endif()
+endif()
--- a/Resources/CMake/OrthancFrameworkConfiguration.cmake	Thu Feb 14 16:22:52 2019 +0100
+++ b/Resources/CMake/OrthancFrameworkConfiguration.cmake	Thu Feb 14 19:41:09 2019 +0100
@@ -94,7 +94,7 @@
 endif()
 
 if (NOT ENABLE_LOCALE)
-  unset(USE_SYSTEM_LIBICONV CACHE)
+  unset(BOOST_LOCALE_BACKEND CACHE)
   add_definitions(-DORTHANC_ENABLE_LOCALE=0)
 endif()
 
@@ -378,16 +378,24 @@
 
 
 ##
-## Locale support: libiconv
+## Locale support
 ##
 
 if (ENABLE_LOCALE)
   if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
     # In WebAssembly or asm.js, we rely on the version of iconv that
     # is shipped with the stdlib
-    unset(USE_BOOST_ICONV CACHE)
+    unset(BOOST_LOCALE_BACKEND CACHE)
   else()
-    include(${CMAKE_CURRENT_LIST_DIR}/LibIconvConfiguration.cmake)
+    if (BOOST_LOCALE_BACKEND STREQUAL "iconv")
+      include(${CMAKE_CURRENT_LIST_DIR}/LibIconvConfiguration.cmake)
+    elseif (BOOST_LOCALE_BACKEND STREQUAL "icu")
+      include(${CMAKE_CURRENT_LIST_DIR}/LibIcuConfiguration.cmake)
+    elseif (BOOST_LOCALE_BACKEND STREQUAL "wconv")
+      message("Using Microsoft Window's wconv")
+    else()
+      message(FATAL_ERROR "Invalid value for BOOST_LOCALE_BACKEND: ${BOOST_LOCALE_BACKEND}")
+    endif()
   endif()
   
   add_definitions(-DORTHANC_ENABLE_LOCALE=1)
@@ -610,6 +618,7 @@
   ${CURL_SOURCES}
   ${JSONCPP_SOURCES}
   ${LIBICONV_SOURCES}
+  ${LIBICU_SOURCES}
   ${LIBJPEG_SOURCES}
   ${LIBP11_SOURCES}
   ${LIBPNG_SOURCES}
--- a/Resources/CMake/OrthancFrameworkParameters.cmake	Thu Feb 14 16:22:52 2019 +0100
+++ b/Resources/CMake/OrthancFrameworkParameters.cmake	Thu Feb 14 19:41:09 2019 +0100
@@ -43,6 +43,7 @@
 set(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
 set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
 set(USE_SYSTEM_LIBICONV ON CACHE BOOL "Use the system version of libiconv")
+set(USE_SYSTEM_LIBICU ON CACHE BOOL "Use the system version of libicu")
 set(USE_SYSTEM_LIBJPEG ON CACHE BOOL "Use the system version of libjpeg")
 set(USE_SYSTEM_LIBP11 OFF CACHE BOOL "Use the system version of libp11 (PKCS#11 wrapper library)")
 set(USE_SYSTEM_LIBPNG ON CACHE BOOL "Use the system version of libpng")
@@ -66,13 +67,13 @@
 # Advanced and distribution-specific parameters
 set(USE_GOOGLE_TEST_DEBIAN_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
 set(SYSTEM_MONGOOSE_USE_CALLBACKS ON CACHE BOOL "The system version of Mongoose uses callbacks (version >= 3.7)")
-set(USE_BOOST_ICONV ON CACHE BOOL "Use iconv instead of wconv (Windows only)")
+set(BOOST_LOCALE_BACKEND "iconv" CACHE STRING "Back-end for locales that is used by Boost (can be \"iconv\", \"icu\", or \"wconv\" on Windows)")
 set(USE_PUGIXML ON CACHE BOOL "Use the Pugixml parser (turn off only for debug)")
 set(USE_LEGACY_JSONCPP OFF CACHE BOOL "Use the old branch 0.x.y of JsonCpp, that does not require a C++11 compiler (for old versions of Visual Studio)")
 
 mark_as_advanced(USE_GOOGLE_TEST_DEBIAN_PACKAGE)
 mark_as_advanced(SYSTEM_MONGOOSE_USE_CALLBACKS)
-mark_as_advanced(USE_BOOST_ICONV)
+mark_as_advanced(BOOST_LOCALE_BACKEND)
 mark_as_advanced(USE_PUGIXML)
 mark_as_advanced(USE_LEGACY_JSONCPP)
 
--- a/UnitTestsSources/FromDcmtkTests.cpp	Thu Feb 14 16:22:52 2019 +0100
+++ b/UnitTestsSources/FromDcmtkTests.cpp	Thu Feb 14 19:41:09 2019 +0100
@@ -1507,7 +1507,8 @@
     int a = boost::lexical_cast<int>(components[0]);
     int b = boost::lexical_cast<int>(components[1]);
     if (a < 0 || a > 15 ||
-        b < 0 || b > 15)
+        b < 0 || b > 15 ||
+        (a == 0 && b == 0))
     {
       throw;
     }
@@ -1543,7 +1544,7 @@
   ParsedDicomFile dicom(false);
   dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 149");
   ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
-              (DCM_PatientName, korean.c_str(), korean.size(), true).good());
+              (DCM_PatientName, korean.c_str(), OFBool(true)).good());
 
   bool hasCodeExtensions;
   Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
@@ -1624,7 +1625,7 @@
   ParsedDicomFile dicom(false);
   dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 87");
   ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
-              (DCM_PatientName, japanese.c_str(), japanese.size(), true).good());
+              (DCM_PatientName, japanese.c_str(), OFBool(true)).good());
 
   bool hasCodeExtensions;
   Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
@@ -1692,7 +1693,7 @@
   ParsedDicomFile dicom(false);
   dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030");
   ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
-              (DCM_PatientName, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good());
+              (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
 
   bool hasCodeExtensions;
   Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
@@ -1754,7 +1755,7 @@
   ParsedDicomFile dicom(false);
   dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030");
   ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
-              (DCM_PatientComments, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good());
+              (DCM_PatientComments, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
 
   bool hasCodeExtensions;
   Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
@@ -1798,7 +1799,7 @@
   ParsedDicomFile dicom(false);
   dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 58");
   ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
-              (DCM_PatientName, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good());
+              (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
 
   bool hasCodeExtensions;
   Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
@@ -1839,7 +1840,7 @@
   ParsedDicomFile dicom(false);
   dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 58");
   ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
-              (DCM_PatientName, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good());
+              (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
 
   bool hasCodeExtensions;
   Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);