# Export DICOM to filesystem fails on UTF-8 characters

**URL:** https://discourse.slicer.org/t/export-dicom-to-filesystem-fails-on-utf-8-characters/16030
**Category:** Feature requests
**Created:** [February 17, 2021, 9:55am UTC](https://discourse.slicer.org/t/export-dicom-to-filesystem-fails-on-utf-8-characters/16030 "2021-02-17T09:55:32Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)
#### Post date: [February 17, 2021, 9:55am UTC](https://discourse.slicer.org/t/export-dicom-to-filesystem-fails-on-utf-8-characters/16030/1 "2021-02-17T09:55:32Z")

</div>

Hi,

My environment’s locale is fr\_FR.UTF-8, which does not always plays well with Slicer, rarely though.

While exporting DICOM series that have accented characters to filesystem, it fails on non-ascii characters as such:

![Screenshot_20210217_104325](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/0/80ad090f5c5b4dab68960637672673dc2ee2d595.png)

> Failed to copy
> 
> to /tmp/Slicer/A10000711888-PATIENT\_NAME/20210210-ANGIOSCANNER MEMBRE INF/201-Images trait�es/000000.dcm Halting export

The directory \<201-Images traitées\> is created on storage.

I fear it’s an issue that can’t be resolved as it relates deeply to Slicer’s internals.

I’m posting here for any magic solution.

Regards.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [February 17, 2021, 11:33am UTC](https://discourse.slicer.org/t/export-dicom-to-filesystem-fails-on-utf-8-characters/16030/2 "2021-02-17T11:33:51Z")

</div>

Since you use UTF8 and latest Slicer Stable Release (or preview releases) uses UTF8 everywhere, there should be no problems with special characters.

What Slicer version and operating system do you use? Can you send the full application log?

---

<div class="post-metadata">

### Author: ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)
#### Post date: [February 17, 2021, 1:29pm UTC](https://discourse.slicer.org/t/export-dicom-to-filesystem-fails-on-utf-8-characters/16030/3 "2021-02-17T13:29:01Z")

</div>

I have the same failure on self built and factory built Slicer on Arch Linux. Here is the application log from factory built :

> Session start time …: 2021-02-17 14:21:33  
> Slicer version …: 4.13.0-2021-02-16 (revision 29713 / b691c46) linux-amd64 - installed release  
> Operating system …: Linux / 5.10.15-arch1-1 / #1 SMP PREEMPT Wed, 10 Feb 2021 18:32:40 +0000 - 64-bit  
> Memory …: 16006 MB physical, 16383 MB virtual  
> CPU …: AuthenticAMD AMD Phenom™ II X6 1100T Processor, 6 cores, 6 logical processors  
> VTK configuration …: OpenGL2 rendering, Sequential threading  
> Qt configuration …: version 5.15.1, with SSL, requested OpenGL 3.2 (core profile)  
> Developer mode enabled …: yes  
> Prefer executable CLI …: yes  
> Application path …: /home/user/programs/Test/Slicer-4.13.0-2021-02-16-linux-amd64/bin  
> Additional module paths …: (none)  
> Reversing DICOM dictionary so can look up tag from a keyword…  
> Scripted subject hierarchy plugin registered: Annotations  
> Scripted subject hierarchy plugin registered: SegmentEditor  
> Scripted subject hierarchy plugin registered: SegmentStatistics  
> Switch to module: “Volumes”  
> Assertion `this->Table->columnWidth(j) == newWidth` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 242  
> Assertion `this->Table->columnWidth(j) == newWidth` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 242  
> Assertion `this->Table->columnWidth(j) == newWidth` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 242  
> Assertion `this->Table->columnWidth(j) == newWidth` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 242  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Assertion `this->Table->rowHeight(i) == newHeight` failed in /work/Preview/Slicer-0-build/CTK/Libs/Widgets/ctkMatrixWidget.cpp line 253  
> Loading Slicer RC file [/home/user/.slicerrc.py]  
> Switch to module: “DICOM”

Not much informative about the failure.

Anyway, I can do without this being fixed. AFAIK, core libraries like VTK, CTK, ITK and others do not expect non-asciii characters.

Thanks.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [February 17, 2021, 1:51pm UTC](https://discourse.slicer.org/t/export-dicom-to-filesystem-fails-on-utf-8-characters/16030/4 "2021-02-17T13:51:41Z")

</div>

> [@chir.set](#):
>
> Anyway, I can do without this being fixed. AFAIK, core libraries like VTK, CTK, ITK and others do not expect non-asciii characters.

We build Slicer with UTF8 application code page on Windows, and UTF8 encoding is used on Linux and macOS by default already. So everything, including VTK, CTK, ITK works well with non-ASCII characters.

If your Linux or macOS system is set to a non-UTF8 locale then you need to restrict yourself to ASCII characters or switch the locale in the environment where you launch Slicer.

There is still an issue in Windows passing command-line arguments from a non-UTF8 terminal to a UTF8 application, but this should be resolved as Windows is gradually moving towards UTF8 everywhere.

**What is the output of `locale` command on your system (in a terminal)?**

**What is the output of this command in Slicer’s Python console?**

```python
localeCodec = qt.QTextCodec().codecForLocale()
print(localeCodec.toUnicode(localeCodec.name()))

```

> [@chir.set](#):
>
> Not much informative about the failure.

I meant the application log of a failed DICOM export. It may contain useful information - most importantly what and where exactly logged the error.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [February 17, 2021, 8:38pm UTC](https://discourse.slicer.org/t/export-dicom-to-filesystem-fails-on-utf-8-characters/16030/5 "2021-02-17T20:38:23Z")

</div>

**Update:** I’ve found that there is an intentional stripping of special characters in the CTK DICOM exporter:

> <https://github.com/commontk/CTK/blob/f670e1d0e513bae9d08257b883aaf669f546053d/Libs/DICOM/Widgets/ctkDICOMBrowser.cpp#L1338>

While the intent is good (you don’t want to create a folder that you may not be able to write to a DVD or USB stick later), but may lead to other complications. I’ve pushed a few fixes, you can try if it works better in the Slicer Preview Release that you download tomorrow or later.

---

<div class="post-metadata">

### Author: ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)
#### Post date: [February 18, 2021, 9:39am UTC](https://discourse.slicer.org/t/export-dicom-to-filesystem-fails-on-utf-8-characters/16030/6 "2021-02-18T09:39:50Z")

</div>

Yes, this fixes the issue. Slicer-4.13.0-2021-02-17 can now export the series, stripping special characters with ‘\_’.

Thank you.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [March 21, 2023, 2:36am UTC](https://discourse.slicer.org/t/export-dicom-to-filesystem-fails-on-utf-8-characters/16030/7 "2023-03-21T02:36:39Z")

</div>


