You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If you create a dataset with 'Value 1 of Attribute Specific Character Set (0008,0005) is Not Present' like '(0008,0005) \ISO 2022 IR 87' AND you have set the DefaultCharacterSet to UTF8, the writing of the dataset fails with a BufferOverflowException.
To Reproduce
Run this test:
@Test
void writeJapanese_setDefaultCharacterSet_Utf8() {
String utf8 = "ISO_IR 192";
SpecificCharacterSet.setDefaultCharacterSet(utf8);
Attributes dataset = new Attributes();
dataset.setString(Tag.SpecificCharacterSet, VR.CS, "", "ISO 2022 IR 87");
dataset.setString(Tag.PatientName, VR.PN, "Yamada^Tarou=山田^太郎=やまだ^たろう");
SpecificCharacterSet specificCharacterSet = dataset.getSpecificCharacterSet();
//codec[0] is 'UTF_8', codec[1] is 'JIS_X_208' ?!?!?!
VR.PN.toBytes(dataset.getValue(Tag.PatientName), specificCharacterSet);
// this fails with a
// java.nio.BufferOverflowException
// at java.base/java.nio.charset.CoderResult.throwException(CoderResult.java:273)
// at org.dcm4che3.data.SpecificCharacterSet$Encoder.encode(SpecificCharacterSet.java:265)
// at org.dcm4che3.data.SpecificCharacterSet$ISO2022.encode(SpecificCharacterSet.java:309)
// therefore any write dataset will fail as well
}
Expected behavior
Writing of any datasets should succeed independent of the set DefaultCharacterSet by SpecificCharacterSet.setDefaultCharacterSet(String code)
Desktop (please complete the following information):
OS: Windows 10
dcm4che 5.22.5
The text was updated successfully, but these errors were encountered:
Will fix it, by falling back to ASCII as default character set, if Specific Character Sets contains multiple code values and Default Character Set was set to "ISO_IR 192".
Describe the bug
If you create a dataset with 'Value 1 of Attribute Specific Character Set (0008,0005) is Not Present' like '(0008,0005) \ISO 2022 IR 87' AND you have set the DefaultCharacterSet to UTF8, the writing of the dataset fails with a BufferOverflowException.
To Reproduce
Run this test:
Expected behavior
Writing of any datasets should succeed independent of the set DefaultCharacterSet by SpecificCharacterSet.setDefaultCharacterSet(String code)
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: