I’m using the itksys tools to do some file parsing and I’ve encountered a nasty problem with some filepaths containing accented characters.
For example I have this folder name in my database : “aorte_déroulée”. It appears that in fact, the “é” symbol is a “e” char followed by a combining acute accent char (I think that data came from a MacOS station).
When using itksys::Directory::Load() on the parent folder, the given string is then “aorte_de´roule´e”, which is fine. Problem is that this path is not recognized as valid afterward: using itksys::Directory::Load("[…]/aorte_de´roule´e") or itksys::SystemTools::FileIsDirectory("[…]/aorte_de´roule´e") fails. Replacing directly by the full char “é” in the string doesn’t help either.
Any insights on why it’s happening and how to fix it ?
(I can rename the folder with the accented letter char, then it will be correctly processed but I can’t control the file naming in my application)
EDIT: It appears to be a Windows-specific issue, as tests on MacOS and Linux run fine. I’ve tracked down the problem to:
- itksys::Directory::Load() fails on (Directory.cxx, l 121)
srchHandle = _wfindfirst_func( (wchar_t*)Encoding::ToWindowsExtendedPath(buf).c_str(), &data);
- itksys::SystemTools::FileIsDirectory fails on (SystemTools.cxx, l 2902)
DWORD attr = GetFileAttributesW(Encoding::ToWindowsExtendedPath(name).c_str());
attr == INVALID_FILE_ATTRIBUTES