pyomeca / ezc3d

Easy to use C3D reader/writer for C++, Python and Matlab
https://pyomeca.github.io/Documentation/ezc3d/index.html
MIT License
142 stars 44 forks source link

Problems with opening files that are located in a folder with "umlaut" letters (ä,ö,ü, ...) #312

Closed BDumphart closed 6 months ago

BDumphart commented 7 months ago

Dear developers!

I am a researcher from Austria and am currently using ezc3d for gathering a massive dataset from a gait laboratory. The problem is that in Austria we have names where the letters ä, ö, or ü can occur and ezc3d cannot open these files with the file path containing these letters. I have tried opening the same .c3d file in a "normal" folder and a folder containing the umlaut letters. Normally, they use the btk tool, because they are using Matlab and do not have this problem. So my question is, can this be somehow fixed easily or do you have any other suggestions?

Thanks for your answer!

Cheers,

Bernhard

pariterre commented 7 months ago

Dear @BDumphart,

Thank you for getting in touch! I completely understand the challenges that arise as a French speaker, where we encounter various letters that aren't as English-friendly—haha!

Unfortunately, this presents a difficult issue. Ezc3d is designed to function across multiple platforms (Windows, Linux, and Mac), each with its own character encoding standards (e.g., ISO 8859-1, utf8, utf16, etc.). Consequently, reliably reading paths becomes quite complex. Furthermore, to my knowledge, there isn't a C++ library available that manipulates paths in the manner required by ezc3d.

In essence, path reading depends on both the coding implemented on my end and the configuration on the user's side. My recommendation, which I've consistently followed in my own projects, is to avoid using any non-English alphabet characters in paths (including é, è, ë, and spaces), with the exception of the underscore "_", which typically works without issues.

That being said, if you're using Mac or Linux, it should theoretically function correctly, as ezc3d assumes utf8 formatting, which is usually the default on these systems unless explicitly reconfigured.

Best regards,

felixchenier commented 7 months ago

Hi @BDumphart Just adding my two cents since I also had this problem with ezc3d and I fixed it using a workaround which is to copy the c3d file to your system's temp folder before opening it. Normally there is no accented characters in the temp folder path. I don't know if you're using Python, but if you are, here is the code I use to locate the system temp folder on macOS or Windows:

import os
import platform

# Operating system
is_pc = True if platform.system() == "Windows" else False
is_mac = True if platform.system() == "Darwin" else False

# Temporary folder
if is_pc and "TEMP" in os.environ:
    temp_folder = os.environ["TEMP"]
elif is_mac and "TMPDIR" in os.environ:
    temp_folder = os.environ["TMPDIR"]
else:
    print("Impossible to get temp folder.")
BDumphart commented 6 months ago

Dear @pariterre and @felixchenier!

Thank you guys for the fast response! :) I had a feeling that this won´t be a simple fix, but thank you for clarifying. I will tell them about this 'problem' and the 'solution'.

I will also try the workaround from @felixchenier!

Thanks,

Bernhard