<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Texte de bulles Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.TextedebullesCar
        {mso-style-name:"Texte de bulles Car";
        mso-style-priority:99;
        mso-style-link:"Texte de bulles";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi,<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><span lang=EN-US>I recently upgrade from itk 3.16 to itk 4.1.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>I thus have to update my code source to use the new gdcm core (2.0.x)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US>Previously, I wrote a method (for internal use) which returns the value of a given Tag as string.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>This method now uses a gdcm::DataElement as parameter.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US>But I can&#8217;t get the value of the DataElement as a string in all the case.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>My code is the following<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:blue'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:blue'>static</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>bool</span> GetValue(std::string &amp;p_Str, <span style='color:blue'>const</span> gdcm::DataElement &amp;p_Elem)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>{<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p_Str.clear();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:green'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>if (p_Elem.GetByteValue() == NULL) return false;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p_Str = std::string(p_Elem.GetByteValue()-&gt;GetBuffer(),p_Elem.GetByteValue()-&gt;GetLength());<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:blue'>return</span> !p_Str.empty();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US>But for a given tag (SamplesPerPixel, which VR = US and Value is 1), p_Str is not &#8220;1&#8221; but &#8220; &#8220;. This seems to indicate that <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'>p_Str = std::string(p_Elem.GetByteValue()-&gt;GetBuffer(),p_Elem.GetByteValue()-&gt;GetLength());<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>is not the correct way to get the value of a US element in a string !<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US>Is there a way to do want I want in a safe manner (not dependent to VR) ?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US>Thanks for help<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US>Vincent<o:p></o:p></span></p></div></body></html>