Skip to content

Paths and filenames are not necessarily UTF-8 #7225

Closed

Description

@huonw
$ mkdir empty
$ cd empty
$ ls
$ touch $(echo -e "\xff") # `ÿ` in latin1, invalid UTF8, but valid filename
$ ls
?
$ rusti
WARNING: The Rust REPL is experimental and may be
unstable. If you encounter problems, please use the
compiler instead. Type :help for help.
rusti> std::os::list_dir(&Path("."))
rust: task failed at 'assertion failed: is_utf8(v)', /home/huon/rust/src/libstd/str.rs:758
terminate called after throwing an instance of 'rust_task*'
Aborted

Path and all interfaces directly with the file-system should probably use [u8] rather than trying to coerce str to handle these cases. (Similar issue to #7188.)

Activity

  1. bblum commented on Jul 3, 2013

    @bblum
    Contributor

    nominating feature-complete

  2. catamorphism commented on Sep 5, 2013

    @catamorphism
    Contributor

    Accepted for backwards-compatible

  3. lilyball commented on Sep 23, 2013

    @lilyball
    Contributor

    My last referenced commit is a month old, but I'm still working on this issue (currently finishing up the support for Windows paths).

  4. pnkfelix commented on Sep 27, 2013

    @pnkfelix
    Contributor

    The issues here of dealing with filesystems that are not utf8 seem related to #2253, at least tangentially.

  5. added a commit that references this issue on May 20, 2021
  6. added a commit that references this issue on Aug 21, 2026
    8b77e26
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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions