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

Localized file names and actual display names #845

Open
steveklabnik opened this issue Feb 14, 2015 · 1 comment
Open

Localized file names and actual display names #845

steveklabnik opened this issue Feb 14, 2015 · 1 comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the RFC.

Comments

@steveklabnik
Copy link
Member

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

For earlier discussion, see rust-lang/rust#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.
@bluss
Copy link
Member

bluss commented Feb 14, 2015

path.display() is also only seriously for display.

@petrochenkov petrochenkov added T-libs-api Relevant to the library API team, which will review and decide on the RFC. and removed A-libs labels Jan 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

3 participants