@@ -53,6 +53,8 @@ impl Shell {
5353 color_choice : auto_clr,
5454 hyperlinks : supports_hyperlinks ( ) ,
5555 stderr_tty : std:: io:: stderr ( ) . is_terminal ( ) ,
56+ stdout_unicode : supports_unicode ( & std:: io:: stdout ( ) ) ,
57+ stderr_unicode : supports_unicode ( & std:: io:: stderr ( ) ) ,
5658 } ,
5759 verbosity : Verbosity :: Verbose ,
5860 needs_clear : false ,
@@ -259,6 +261,20 @@ impl Shell {
259261 Ok ( ( ) )
260262 }
261263
264+ pub fn out_unicode ( & self ) -> bool {
265+ match & self . output {
266+ ShellOut :: Write ( _) => true ,
267+ ShellOut :: Stream { stdout_unicode, .. } => * stdout_unicode,
268+ }
269+ }
270+
271+ pub fn err_unicode ( & self ) -> bool {
272+ match & self . output {
273+ ShellOut :: Write ( _) => true ,
274+ ShellOut :: Stream { stderr_unicode, .. } => * stderr_unicode,
275+ }
276+ }
277+
262278 /// Gets the current color choice.
263279 ///
264280 /// If we are not using a color stream, this will always return `Never`, even if the color
@@ -384,6 +400,8 @@ enum ShellOut {
384400 stderr_tty : bool ,
385401 color_choice : ColorChoice ,
386402 hyperlinks : bool ,
403+ stdout_unicode : bool ,
404+ stderr_unicode : bool ,
387405 } ,
388406}
389407
@@ -519,6 +537,10 @@ fn supports_color(choice: anstream::ColorChoice) -> bool {
519537 }
520538}
521539
540+ fn supports_unicode ( stream : & dyn IsTerminal ) -> bool {
541+ !stream. is_terminal ( ) || supports_unicode:: supports_unicode ( )
542+ }
543+
522544fn supports_hyperlinks ( ) -> bool {
523545 #[ allow( clippy:: disallowed_methods) ] // We are reading the state of the system, not config
524546 if std:: env:: var_os ( "TERM_PROGRAM" ) . as_deref ( ) == Some ( std:: ffi:: OsStr :: new ( "iTerm.app" ) ) {
0 commit comments