Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode filesystem path support for Windows #116

Open
jdlangs opened this issue Dec 22, 2020 · 10 comments
Open

Unicode filesystem path support for Windows #116

jdlangs opened this issue Dec 22, 2020 · 10 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@jdlangs
Copy link

jdlangs commented Dec 22, 2020

I'm trying to build this repository for Windows 10 UWP and am hitting the hardcoded error that unicode is not supported (from @hidmic in #35). From looking at this just for a few minutes, it seems it should be feasible to use the wide character versions of the Windows API calls and convert the data to a UTF8 encoded std::string in this case. Does this seem reasonable? Was there a reason it wasn't done this way initially?

@hidmic
Copy link
Contributor

hidmic commented Dec 22, 2020

Does this seem reasonable?

While UTF-8 encoding would definitely be an option, these helpers aim to mimic std::filesystem, available in C++17 STL onwards. The latter uses std::wstring if need be instead, and I'd rather not deviate too much.

Was there a reason it wasn't done this way initially?

Lack of need and consistency. As you may have realized already, neither rcpputils nor rcutils attempt to handle wide characters. And AFAIK i18n support is not in the near term roadmap. Contributions are most welcomed though.

Tagging @clalancette and the @ros2/team for additional feedback.

@hidmic hidmic added enhancement New feature or request help wanted Extra attention is needed labels Dec 22, 2020
@wjwwood
Copy link
Member

wjwwood commented Dec 22, 2020

While UTF-8 encoding would definitely be an option, these helpers aim to mimic std::filesystem, available in C++17 STL onwards. The latter uses std::wstring if need be instead, and I'd rather not deviate too much.

I wouldn't deviate at all. The goal would be to replace this interface with std::filesystem entirely without downstream changes.

@clalancette
Copy link
Contributor

I wouldn't deviate at all. The goal would be to replace this interface with std::filesystem entirely without downstream changes.

Right, exactly. And with Galactic probably switching to C++17 support, that may be feasible now. Whether we get to it is another question.

@jdlangs
Copy link
Author

jdlangs commented Dec 22, 2020

Thanks all, that helps me understand the context a lot better. If I were to put in some time on this over the next few weeks what would be the recommended approach to solving this?

@clalancette
Copy link
Contributor

The long-term plan is to remove rcpputils::fs completely in favor of std::filesystem. But I don't think we are quite there yet.

So that leaves us with implementing this functionality in rcpputils::fs in a 100% compatible way with std::filesystem. If you want to have an implementation you can get in right now (and backport to Foxy), you'll have to figure out how to do that without std::filesystem. If you want to make a bit of a leap and assume we'll go with C++17 for Galactic (as in ros-infrastructure/rep#291), then you can use std::filesystem to do the implementation.

Does that all make sense?

@jdlangs
Copy link
Author

jdlangs commented Dec 23, 2020

Makes sense. For a Foxy compatible option, would it be appropriate to grab an existing 3rd party filesystem header library and rely on that before later switching it to the standard lib? This one seems fairly popular.

@clalancette
Copy link
Contributor

Makes sense. For a Foxy compatible option, would it be appropriate to grab an existing 3rd party filesystem header library and rely on that before later switching it to the standard lib? This one seems fairly popular.

I have to say that I'm not enthusiastic about adding a new dependency that we'll have to vendor. While it is more work, could we just code the functionality into rcpputils::fs for Foxy?

@jdlangs
Copy link
Author

jdlangs commented Jan 4, 2021

a new dependency that we'll have to vendor

Is it off the table to simply include the single header file in the repo? If so, I'll just make a PR that uses std::filesystem directly for Galactic.

@wjwwood
Copy link
Member

wjwwood commented Jan 4, 2021

I'm not opposed to including a dependency like the one you linked to, personally, since those are designed to be easily incorporated into a project. But I do agree with @clalancette that it's more straight forward to fix this as narrowly as possible in foxy, due to testing and ABI concerns (like if the size of Path changed due to this vendoring, that would be an issue for backporting).

For newer versions, like rolling and galactic, having this more complete implementation as a fallback isn't a terrible idea, imo. However, I have some lingering concerns about it:

  • There appears to be some differences from the official version w.r.t. unicode depending on the C++ version used:
  • issues for users wanting to certify and/or test our code at a higher level
    • this basically boils down to: "more code == bad", so our implementation of a few features, while lacking, is easier to handle than the >6kloc from this project that was linked
  • deciding when to update this dependency or remove it, in the future (on going maintenance burden)
    • though to be fair we have something similar already with our custom implementation

@jdlangs
Copy link
Author

jdlangs commented Jan 5, 2021

So I did some experimenting and the external filesystem library doesn't even build on UWP anyways, which is my original problem. So it would seem the best option is to just update to C++17 and std::filesystem for Galactic and not bother with backporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants