nieljake
 Basic Member Posts:23
 |
| 2010-07-28 12:39 PM |
|
Consider the following for patient name:
(0008,0005) Specific Character Set = ISO 2022 IR 13\ISO 2022 IR 87
(0010,0010) Patient's Name = ENDO^HISASHI=エンドウ^ヒサシ=遠藤^久史
When the following is used:
Platform.Log(LogLevel.Info, "Patient's Name: " + msg.DataSet[DicomTags.PatientsName].GetString(0,""));
The result is:
2010-07-28 11:24:52,718 [3888] [10] INFO - Patient's Name: ENDO^HISASHI=?????^???=??^??
Question marks replace the Ideographic Name and the Phonetic Name in the logging. These characters are preserved and sent across in the dataset during a C-Store.
Is there any method to retrieve these characters from the dataset for logging or display properly?
|
|
|
|
|
steve
 Senior Member Posts:1885
 |
| 2010-07-30 03:28 PM |
|
Jake, Basically, the library is expecting to work with data in Unicode. There's some conversion routines when we parse a DICOM File to automatically do the conversion, and then we go back again when we write the data out. You should always be getting the data in Unicode out of the library, which would allow the extended characters. How was the file read in? Was it something you had encoded, or was it just read in from disk? Perhaps there's something with this. The other thing is perhaps log4net is not dealing with these strings properly, although I thought that was fine... Steve
|
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
nieljake
 Basic Member Posts:23
 |
| 2010-08-02 02:43 PM |
|
The file is read in using the following from disk. These are sample files provided to us from customers.
DF.Load(DicomReadOptions.Default | DicomReadOptions.ReadNonPart10Files);
One thing to note is if I do this:
TagValue = DAToWrite.GetString(0, "")
SWToWriteTo.WriteLine(TagValue);
where DAToWrite is a DicomAttribute object, and SWToWriteTo is a StreamWriter object, then the text output is correct and shows all characters properly.
whereas accessing the value in this way gives only question marks for unicode characters.
msg.DataSet[DicomTags.PatientsName].GetString(0,""));
|
|
|
|
|
nieljake
 Basic Member Posts:23
 |
| 2010-08-03 12:04 PM |
|
I did some more checking and found if I use the value obtained from:
msg.DataSet[DicomTags.PatientsName].GetString(0,""));
and write it to a file using a streamwriter, then all charcters are correct. It appears that the problem would be with log4net, and using a statment like:
Platform.Log(LogLevel.Info, "Patient's Name: " + msg.DataSet[DicomTags.PatientsName].GetString(0,"")); |
|
|
|
|
steve
 Senior Member Posts:1885
 |
| 2010-08-03 12:14 PM |
|
Jake, What if you did something like this: Platform.Log(LogLevel.Info, "Patient's Name: {0}", msg.DataSet[DicomTags.PatientsName].GetString(0,"")); Is this any different? Not sure if it would, but it would be worth a try. Steve
|
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
nieljake
 Basic Member Posts:23
 |
| 2010-08-05 04:05 PM |
|
I tried your suggestion and the results are the same. Any double byte characters are written to the log file as question marks. |
|
|
|
|
steve
 Senior Member Posts:1885
 |
| 2010-08-06 01:09 PM |
|
Jake,
I did some searching about this on the web. It looks like there's a way to set the encoding used in the text files via the Logging.config file. Ie, you can add something like this in your appender section of the config file:
<encoding value="utf-8" />
Could you check this out? One other bit of followup, this is the site I found the reference to setting encoding.
Thanks,
Steve |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
nieljake
 Basic Member Posts:23
 |
| 2010-08-27 01:48 PM |
|
Steve,
Sorry release time so we are busy. I reviewed the website and also did some more looking. I tried your suggestion of for encoding:
utf-8
as well as other I found like:
unicode, and unicodeFFFE
but none seem to produce proper character output. I can get rid of the question marks, but the are only replaced by other improper characters. For example:
2010-08-27 12:47:45,750 [4944] [5] INFO - Patient's Name: ï½´ï¾ï¾„゙ウ ヒサシ
|
|
|
|
|
steve
 Senior Member Posts:1885
 |
| 2010-08-27 06:23 PM |
|
Jake,
I just did a test, when i add the encoding section into the log4net file, it works, when I don't have it, my log files have the ?? marks. This is what the file I created looks like:
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<!-- Define some output appenders -->
<appender name="RollingLogFileAppender" type="ClearCanvas.Common.log4net.RollingFileAppender, ClearCanvas.Common">
<param name="File" value=".\\logs\\ClearCanvas.Test.log" />
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="0" />
<param name="MaximumFileSize" value="256KB" />
<param name="RollingStyle" value="Size" />
<param name="StaticLogFileName" value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p - %m%n" />
</layout>
<lockingModel type="ClearCanvas.Common.log4net.FileAppender+MutexLock, ClearCanvas.Common" />
<encoding value="utf-8" />
</appender>
<!-- Setup the root category, add the appenders and set the default level -->
<root>
<level value="INFO" />
<appender-ref ref="RollingLogFileAppender" />
</root>
<logger name="NHibernate">
<level value="WARN" />
</logger>
</log4net
Can you check what you did again?
Steve |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
nieljake
 Basic Member Posts:23
 |
| 2010-08-31 02:51 PM |
|
Steve,
I tried again using your example and you are correct it worked. The only difference I saw in mine was I had the line with:
encoding value="utf-8"
above the line with:
lockingModel type="ClearCanvas.Common..."
After making this changed it all worked. Thanks much for your help!
|
|
|
|
|
steve
 Senior Member Posts:1885
 |
| 2010-08-31 02:54 PM |
|
Jake, Glad to hear that worked! I entered a ticket to make the change in some of our products also, we have the same issue with the logs as you were having, so this should help us out also. Steve |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|