Skip to content

Commit

Permalink
Restructured code of method convertString().
Browse files Browse the repository at this point in the history
Restructured code of the convertString() method by splitting it into two
methods: one for strings without and one for strings with code extension
techniques according to ISO 2022. This should increase the readability
of the code.
  • Loading branch information
jriesmeier committed Jan 14, 2025
1 parent 739177d commit 8d8d1dd
Show file tree
Hide file tree
Showing 2 changed files with 335 additions and 273 deletions.
35 changes: 33 additions & 2 deletions dcmdata/include/dcmtk/dcmdata/dcspchrs.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2011-2017, OFFIS e.V.
* Copyright (C) 2011-2025, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
Expand Down Expand Up @@ -36,7 +36,7 @@ class DcmItem;

/** A class for managing and converting between different DICOM character sets.
* The conversion relies on the OFCharacterEncoding class, which again relies
* on an underlying character encoding library (e.g. libiconv or ICU).
* on an underlying character encoding library (e.g. oficonv or libiconv).
* @note Please note that a current limitation is that only a single value is
* allowed for the destination character set (i.e. no code extensions). Of
* course, for the source character set, also multiple values are supported.
Expand Down Expand Up @@ -254,6 +254,37 @@ class DCMTK_DCMDATA_EXPORT DcmSpecificCharacterSet
*/
OFCondition selectCharacterSetWithCodeExtensions(const unsigned long sourceVM);

/** convert the given string from the selected source character set (without
* code extensions) to the selected destination character set
* @param fromString input string to be converted
* @param fromLength length of the input string (in bytes)
* @param toString reference to variable where to store the converted
* string
* @param delimiters string of characters regarded as delimiters
* @return status, EC_Normal if successful, an error code otherwise
*/
OFCondition convertStringWithoutCodeExtensions(const char *fromString,
const size_t fromLength,
OFString &toString,
const OFString &delimiters);

/** convert the given string from the selected source character set(s) to
* the selected destination character set. This method supports code
* extension techniques according to ISO 2022 for the input string.
* @param fromString input string to be converted
* @param fromLength length of the input string (in bytes)
* @param toString reference to variable where to store the
* converted string
* @param delimiters string of characters regarded as delimiters
* @param hasEscapeChar flag indicating wether the input string contains
* one or more escape characters (ESC)
* @return status, EC_Normal if successful, an error code otherwise
*/
OFCondition convertStringWithCodeExtensions(const char *fromString,
const size_t fromLength,
OFString &toString,
const OFString &delimiters,
const OFBool hasEscapeChar);

/** check whether the given string contains at least one escape character
* (ESC), because it is used for code extension techniques like ISO 2022
Expand Down
Loading

0 comments on commit 8d8d1dd

Please sign in to comment.