I conducted the following tests regarding VTK's support for UTF8 encoded Chinese paths

vtkDataSetReader ✓
vtkOBJReader ✓
vtkSTLReader ✓
vtkOpenFOAMReader : can update but get 0 block
vtkTecplotReader : can update but get 0 block
vtkCGNSReader : There is no problem with the individual CGNS files, but for the two associated CGNS files, there is an error “File Open Error: OLD - File does not exist” when reading the associated files, located in vtkCGNSReaderInternal.cxx

I perform encoding conversion from “CPACP” to “CPUTF8” using the following code:

std::string toUTF8(const char *ch)
{

    QString filepath = *new QString(ch);
    QByteArray cdata = filepath.toUtf8();
    std::string FilePath = cdata.toStdString();
    return FilePath;
}

I believe these issues can also occur on other non UTF8 systems. Is there any way to solve them?

If you use UTF8 everywhere then everything should work well. On Windows, make sure you set the application manifest to use UTF8.

Thanks for your reply. I’ll try it again.

Thanks, this is useful information. We would like these readers to just work with unicode filenames, without any configuration settings. There is an open issue for this (#17779).

  1. vtkOpenFOAMReader fails because it uses vtkDirectory, and vtkDirectory is broken for UTF-8 on Windows.
  2. vtkTecplotReader fails because it calls gzopen() for compressed files, it needs to use gzopen_w() on WIndows.
  3. vtkCGNSReader fails because the cgns library uses _open() instead of _wopen() on WIndows. This might not be fixable in VTK, it might have to be fixed in the cgns repository.

Thanks for your useful information! It sounds like most of these issues will be fixed internally in VTK, except for CGNS. Will those fixes be in version 9.4?

Most of the fixes will be in VTK 9.4. This includes vtkTecplotReader, vtkOpenFOAMReader, vtkTIFFReader, vtkNIFTIReader, vtkDICOMImageReader.

CGNS is unlikely to be fixed by then. There is a possibility VTK’s HDF readers will be fixed, since hdf5 1.15 will be utf8-friendly, but it doesn’t have an announced release date.

1 Like

The repair of these classes has been very helpful to me. Thank you again for your reply!