Skip to content

investigate handling of windows file paths which are invalid utf-16le #1774

Closed

Description

@andrewrk

Thanks to @daurnimator for pointing this out on #1773
According to https://simonsapin.github.io/wtf-8/, Windows file paths are not necessarily valid utf-16le. When using Windows APIs the zig standard library should not panic or return an encoding error when encountering such file paths.

Zig's cross platform file system abstractions must handle this, plus unix file paths which are null terminated byte arrays.

Potentially we could decode into WTF-8 rather than UTF-8 on Windows, however then it may become subtle to know what kind of operations are allowed on file paths. For example, the algorithm for concatenation is different for each encoding.

Related: #534

Activity

  1. added
    standard library
    os-windows
    on Nov 23, 2018
  2. added this to the 0.5.0 milestone on Nov 23, 2018
  3. daurnimator commented on Nov 24, 2018

    @daurnimator
    Contributor

    I wonder if we just need a type "FilePath" that is distinct from []u8. That way we don't do needless conversions if you're going from e.g. a directory iterator to opening files.

    Though I'm afraid FilePath might end up being a middling solution that makes things more difficult while leaving some corner cases unhandled. e.g. I think different filesystems have different limitations: some are case insensitive, windows will blow up if you use the non \??\ prefix and use filenames like NUL

    However the more I think about it, a FilePath type would be a correct place for handling that sort of thing!

  4. modified the milestones: 0.5.0, 0.6.0 on Aug 16, 2019
  5. modified the milestones: 0.6.0, 0.7.0 on Dec 31, 2019
  6. modified the milestones: 0.7.0, 0.8.0 on Oct 30, 2020
  7. modified the milestones: 0.8.0, 0.9.0 on Nov 6, 2020
  8. modified the milestones: 0.9.0, 0.10.0 on May 19, 2021
  9. added 3 commits that reference this issue on Feb 19, 2024
    690a060
    9bbead3
    68b8791
  10. modified the milestones: 0.15.0, 0.12.0 on Feb 25, 2024
  11. added a commit that references this issue on Feb 25, 2024
    63d16d5
  12. added a commit that references this issue on Mar 20, 2024
    7118375
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    os-windowsstandard library

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions