[vtkusers] vtkDICOMReader read chinese character problem
Ang
ysa0829 at gmail.com
Thu Mar 30 22:52:34 EDT 2017
Hi David,
My character default setting is UTF-8 and the Transfer Syntax UID is
"1.2.840.10008.1.2.4.91"
.
Finally, I found the solution that gdcmReader needs the filename to be
ansi(I guess), I add below code in vtkDICOMReader at line 1460 to 1470.
***********************************************
gdcm::ImageReader reader;
int len = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
wchar_t* wfilename = new wchar_t[len + 1];
memset(wfilename, 0, len * 2 + 2);
MultiByteToWideChar(CP_UTF8, 0, filename, -1, wfilename, len);
len = WideCharToMultiByte(CP_ACP, 0, wfilename, -1, NULL, 0, NULL, NULL);
char* szfilename = new char[len + 1];
memset(szfilename, 0, len + 1);
WideCharToMultiByte(CP_ACP, 0, wfilename, -1, szfilename, len, NULL,
NULL);
std::string strTemp(szfilename);
if (wfilename) delete[] wfilename;
if (szfilename) delete[] szfilename;
reader.SetFileName(strTemp.c_str());
****************************************************
Is this solution better?
--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkDICOMReader-read-chinese-character-problem-tp5742672p5742685.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list