Skip to content

Filename-taking methods do not work with Unicode filenames on windows #6

@MHebes

Description

@MHebes

Nice library!

The ReadStlFile_ASCII, ReadStlFile_BINARY, and StlFileHasASCIIFormat functions all take const char* for the filename.

On windows this causes issues when opening filenames which contain Unicode (UTF-16) strings.

The issue is the ifstream(const char*) constructor, which on windows will only accept ascii strings.

Possible solutions/ideas:

  • Templatize the function on CharT
  • Overload the function on windows only with a version which takes a const wchar_t* or possibly const char16_t* (this is the easiest to monkey-patch in lieu of a fix)
  • (C++17 only) Take a std::filesystem::path as an argument instead of a const char*, which should do all the conversions for you and just do the right thing on all platforms. Would be backwards compatible, since const char* converts to a path implicitly.
  • Have the function take an arbitrary istream instead of requiring filenames (would support e.g. piping easier this way I guess)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions