rust-lang / rust-lang/rfcs

Localized file names and actual display names

Open
#845 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T-libs
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

Issue by pornel
Friday Jan 23, 2015 at 22:38 GMT

For earlier discussion, see https://github.com/rust-lang/rust/issues/21569

This issue was labelled with: A-io, A-libs, A-mac-osx in the Rust repository


In OS X you're not supposed to display POSIX paths to users. User-facing file names are supposed to use "display name" ([NSFilemanager displayNameAtPath:] and friends).

Rust's path.display() and Display guidelines sound like they're exactly for this purpose, but unfortunately path.display() falls short on OS X and probably can't be fixed without breaking at least some Cargo build scripts.

However, in OS X "display path" is seriously only for display and it's a one-way function:

[fm displayNameAtPath:@"/Applications"] == @"アプリケーション"; // If Japanese locale is set
[fm displayNameAtPath:@"foo:bar"] == @"foo/bar"; // Yes, Finder allows slashes in file names

I'd be lovely if Rust had built-in support for this and encouraged doing the right thing on OS X and other OSes that have localized paths.

Suggestions:

  • Add path.filename_localized() and path.components_localized()
  • Drop path.filename_display()
  • Rename path.display() to path.to_string_lossy(), to make it clear that a code like println!("cargo:root={}", path.display()); is slightly buggy.
  • Add format_bytes!() to make it easier to correctly format commandline arguments with paths.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the earlier discussion in rust-lang/rust#21569 and the linked NSFileManager displayNameAtPath documentation, then compare them with Rust's path.display() and Display guidelines. Done means the scope for localized and display path APIs is decided, including the proposed formatting behavior and platform implications.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, rust
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.