From b6713c838d155a1395b5371d2d29cb60552c0f6f Mon Sep 17 00:00:00 2001
From: Slaven Rezic <slaven@rezic.de>
Date: Mon, 11 Feb 2013 17:00:26 +0100
Subject: [PATCH] fix leo script when running in non-latin1 terminals (e.g. utf-8)

See https://rt.cpan.org/Public/Bug/Display.html?id=35543
---
 leo |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/leo b/leo
index eec6ac1..09fe90e 100755
--- a/leo
+++ b/leo
@@ -61,6 +61,8 @@ sub debug;
 
 my($o_s, $o_m, $o_c, $o_l, $o_v, $o_h, $o_n, $o_f, $o_d, $o_u, $o_p);
 
+isatty(1) && eval q{ use open OUT => ':locale'};
+
 #
 # commandline options
 #
@@ -98,6 +100,14 @@ if (!$string) {
   $string = <STDIN>;
   chomp $string;
 }
+if (eval { require I18N::Langinfo; require Encode; 1 }) {
+  my $codeset = I18N::Langinfo::langinfo(I18N::Langinfo::CODESET());
+  if ($codeset) {
+    for ($string) {
+      $_ = Encode::decode($codeset, $_);
+    }
+  }
+}
 
 #
 # open the config, if any
-- 
1.7.2.5