L_DicomSetStringValue2

#include "Ltdic.h"

L_LTDIC_API L_BOOL L_DicomSetStringValue2(hDS, pElement, pValue, nCount)

Sets the string value(s) of a Data Element using default DICOM character set (DICOM_CHARACTER_SET_DEFAULT).

Parameters

HDICOMDS hDS

A DICOM handle.

pDICOMELEMENT pElement

Pointer to a DICOMELEMENT structure within the Data Set.

L_TCHAR * pValue

Pointer to a or character string that contains the string value(s) to set. If you want to set multiple values in the Value Field, put all string values in this string and set nCount to the appropriate number of values.

L_UINT32 nCount

Value that indicates the number of values to set in the Value Field. If you want to set multiple values in the Value Field, put all the string values in pValue and set nCount to the appropriate number.

Returns

Value Meaning
TRUE The string value(s) were set successfully.
FALSE Could not set the string value(s) of the Data Element.

Comments

To set the string value(s) of a Data Element using a specific Character Set value, use L_DicomSetStringValue.

Note: You must allocate the memory for pValue.

If you want to set more than one value in the Value Field of the Data Element, put all the string values in pValue and set nCount to the corresponding number of entries. For example, if you wish to set three string values in the Value Field of the Data Element, put all three strings in pValue, separated by the "0" delimiter and set nCount to three. For example, the illustration below shows a character string, containing three strings separated by the 0 delimiter.

image\String.gif

For more information on required delimiters between multiple values, refer to An Overview of the DICOM File Format and the DICOM Standard.

If more than one value is stored in the Value Field of the Data Element, you must set all values at the same time.

This function can be called only if the Value Representation of the Data Element is VR_AE, VR_CS, VR_LO, VR_LT, VR_SH, VR_ST, VR_UI, VR_UT, or VR_PN. For more information about Value Representations, refer to Default Value Representation Table.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example sets the string value of patient name element using two different methods:

  1. by using the existing specific character set DICOM element
  2. by specifying a character set
    // Forward Declaration 
    L_BOOL SetSpecificCharacterSet(LDicomDS *pDS, L_TCHAR *pszCharacterSet); 
     
    L_INT DicomSetStringValueExample(L_VOID) 
    { 
       LDicomDS ds(TEXT("")); 
       L_TCHAR *pszJapaneseText1 = TEXT("亜美"); 
       pDICOMELEMENT pElement = NULL; 
     
       // Example 1 - uses Specific Character Set Attribute (0008,0005) to set one string 
       ds.ResetDS(); 
       SetSpecificCharacterSet(&ds,  TEXT("ISO_IR 192") );     // Unicode in UTF-8 
       pElement = ds.InsertElement(NULL, FALSE, TAG_PATIENT_NAME, VR_PN, FALSE, 0); 
       ds.SetStringValue(pElement, pszJapaneseText1, 1); 
       L_TCHAR *pszResult = ds.GetStringValue(pElement, 0, 1); 
       lstrcmp(pszResult, pszJapaneseText1); 
       assert(lstrcmp(pszResult, pszJapaneseText1) == 0); 
     
       // Example 2 - pass in a DicomCharacterSet and set one string 
       ds.ResetDS(); 
       pElement = ds.InsertElement(NULL, FALSE, TAG_PATIENT_NAME, VR_PN, FALSE, 0); 
       ds.SetStringValue(pElement, pszJapaneseText1, 1, DICOM_CHARACTER_SET_UNICODE_IN_UTF8); 
       pszResult = ds.GetStringValue(pElement, 0, 1); 
       assert(lstrcmp(pszResult, pszJapaneseText1) == 0); 
     
       return DICOM_SUCCESS; 
    } 
     
    L_BOOL SetSpecificCharacterSet(LDicomDS *pDS, L_TCHAR *pszCharacterSet) 
    { 
       if (pDS == NULL) 
       { 
          return FALSE; 
       } 
     
       if(pszCharacterSet == NULL) 
       { 
          return FALSE; 
       } 
     
       pDICOMELEMENT pElement = pDS->InsertElement(NULL, FALSE, TAG_SPECIFIC_CHARACTER_SET, VR_CS, FALSE, 0); 
       if (pElement == NULL) 
       { 
          return FALSE; 
       } 
     
       return pDS->SetStringValue(pElement, pszCharacterSet, 1); 
    } 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C API Help