Expand description

Formatters for printing filenames and other strings in a terminal, with attention paid to special characters and invalid unicode.

They will wrap quotes around them and add the necessary escapes to make them copy/paste-able into a shell.

The Quotable trait adds quote and maybe_quote methods to string types. The Quoted type has constructors for more explicit control.

Examples

use std::path::Path;
use os_display::Quotable;

let path = Path::new("foo/bar.baz");

// Found file 'foo/bar.baz'
println!("Found file {}", path.quote());
// foo/bar.baz: Not found
println!("{}: Not found", path.maybe_quote());

If the windows/unix features are enabled:

use os_display::Quoted;

// "foo`nbar"
println!("{}", Quoted::windows("foo\nbar"));
// $'foo\nbar'
println!("{}", Quoted::unix("foo\nbar"));

Structs

A wrapper around string types for displaying with quoting and escaping applied.

Traits

An extension trait to apply quoting to strings.