← Back to team overview

kicad-developers team mailing list archive

filename fun

 

Hi folks,

 This whole thing with UTF-8 filenames in Windows is a disaster.
What I've found so far:

1. Regarding OCE: Since OCE 0.17 (OpenCascade 6.8) UTF8
filenames have been supported when built with MSVC but
obviously not with MinGW.

2. MinGW does not provide any means of transparently using
UTF-8 filenames. All filenames within the STL *must* be
char* and MinGW *will* simply pass these on to OpenFileA()
on Windows resulting in UTF-8 being interpreted as ASCII-8
(and who uses ASCII-8 filenames anyway).

So everything hinges on (2). If OCE uses std::stream then
fixing all issues under Windows is a lost cause. If OCE
simply plays with FILE* then it can be patched to work
in MinGW by invoking _wfopen() rather than fopen().

As for kicad itself, std::stream is used in:
(a) VRML export
(b) IDF static library
(c) Scenegraph dynamic library for 3D plugins

2 paths forward come to mind and both will involve some work:

(1) Move to the MSVC build system on Windows: this makes
it possible for us to use Microsoft extensions to STL to deal
with non-ASCII filename issues. There is no need to dig into
the OCE code since we know it will work correctly when built
with MSVC.

(2) Rework kicad code to play with FILE* (or wxFileStream)
rather than std::ifstream/ofstream. Although this will fix the
issues which are confined to kicad's source, it does nothing
to address the OCE issue. Whether or not OCE in MinGW
is a lost cause remains to be seen.

One other possibility (but one which I hadn't looked into)
is to see if the STL implementation within MinGW uses the
MinGW-CRT. If it does then it may be possible to fix
everything by ensuring that the MinGW-CRT converts all
filenames to UTF16 and opens a file using FileOpenW().
In all cases this is not a pleasant task.

Any comments/suggestions?

- Cirilo


Follow ups