<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>t/014utf8.t</filename>
    </added>
    <added>
      <filename>t/canned/utf8.txt</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,9 +2,11 @@
 Revision history for Sysadm::Install
 ########################################
 
-0.30 (not yet released)
+0.30 2009/08/27
     (ms) nhandler(at)ubuntu.com provided a patch to resolve pod2man errors:
          https://rt.cpan.org/Public/Bug/Display.html?id=47525
+    (ms) slurp() and blurt() now use utf8 mode by default if available
+    (ms) added utf8_available() and is_utf8_data()
 
 0.29 2009/06/25
     (ms) Greg Olszewski added proper error handling to print and </diff>
      <filename>Changes</filename>
    </modified>
    <modified>
      <diff>@@ -23,5 +23,7 @@ t/010carp.t
 t/011defor.t
 t/012tap.t
 t/013download.t
+t/014utf8.t
 t/canned/test.tar
 t/canned/testa.tar
+t/canned/utf8.txt</diff>
      <filename>MANIFEST</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 ######################################################################
-    Sysadm::Install 0.30
+    Sysadm::Install 0.31
 ######################################################################
 
 NAME
@@ -447,6 +447,16 @@ DESCRIPTION
         apparently passed in by value? Modifying $_[0] within the subroutine
         is an old Perl trick to do exactly that.
 
+    &quot;is_utf8_data($data)&quot;
+        Check if the given string has the utf8 flag turned on. Works just
+        like Encode.pm's is_utf8() function, except that it silently returns
+        a false if Encode isn't available, for example when an ancient perl
+        without proper utf8 support is used.
+
+    &quot;utf8_check($data)&quot;
+        Check if we're using a perl with proper utf8 support, by verifying
+        the Encode.pm module is available for loading.
+
 AUTHOR
     Mike Schilli, &lt;m@perlmeister.com&gt;
 </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ use 5.006;
 use strict;
 use warnings;
 
-our $VERSION = '0.30';
+our $VERSION = '0.31';
 
 use File::Copy;
 use File::Path;
@@ -84,6 +84,7 @@ sudo_me bin_find
 fs_read_open fs_write_open pipe_copy
 snip password_read nice_time
 def_or blurt_atomic
+is_utf8_data utf8_available
 );
 
 our %EXPORTABLE = map { $_ =&gt; 1 } @EXPORTABLE;
@@ -667,6 +668,11 @@ sub pie {
 
         open FILE, &quot;&lt;$file&quot; or 
             LOGCROAK(&quot;Cannot open $file ($!)&quot;);
+
+        if( utf8_available() ) {
+            binmode FILE, &quot;:utf8&quot;;
+        }
+
         while(&lt;FILE&gt;) {
             $out .= $coderef-&gt;($_);
         }
@@ -707,6 +713,11 @@ sub plough {
 
         open FILE, &quot;&lt;$file&quot; or 
             LOGCROAK(&quot;Cannot open $file ($!)&quot;);
+
+        if( utf8_available() ) {
+            binmode FILE, &quot;:utf8&quot;;
+        }
+
         while(&lt;FILE&gt;) {
             $coderef-&gt;($_);
         }
@@ -741,6 +752,9 @@ sub slurp {
         INFO &quot;Slurping data from $file&quot;;
         open FILE, &quot;&lt;$file&quot; or 
             LOGCROAK(&quot;Cannot open $file ($!)&quot;);
+        if( utf8_available() ) {
+            binmode FILE, &quot;:utf8&quot;;
+        }
         $data = &lt;FILE&gt;;
         close FILE;
         DEBUG &quot;Read &quot;, snip($data, $DATA_SNIPPED_LEN), &quot; from $file&quot;;
@@ -778,6 +792,11 @@ sub blurt {
     open FILE, &quot;&gt;&quot; . ($append ? &quot;&gt;&quot; : &quot;&quot;) . $file 
         or 
         LOGCROAK(&quot;Cannot open $file for writing ($!)&quot;);
+
+    if( is_utf8_data( $data ) ) {
+        binmode FILE, &quot;:utf8&quot;;
+    }
+
     print FILE $data
         or 
         LOGCROAK(&quot;Cannot write to $file ($!)&quot;);        
@@ -1541,6 +1560,50 @@ sub def_or($$) {
     }
 }
 
+=item C&lt;is_utf8_data($data)&gt;
+
+Check if the given string has the utf8 flag turned on. Works just like 
+Encode.pm's is_utf8() function, except that it silently returns a 
+false if Encode isn't available, for example when an ancient perl 
+without proper utf8 support is used.
+
+=cut
+
+###############################################
+sub is_utf8_data {
+###############################################
+    my($data) = @_;
+
+    if( !utf8_available() ) {
+        return 0;
+    }
+
+    return Encode::is_utf8( $data );
+}
+
+=item C&lt;utf8_check($data)&gt;
+
+Check if we're using a perl with proper utf8 support, by verifying the
+Encode.pm module is available for loading.
+
+=cut
+
+###############################################
+sub utf8_available {
+###############################################
+
+    eval {
+        use Encode;
+    };
+
+    if($@) {
+        return 0;
+    }
+
+    return 1;
+}
+
+
 =pod
 
 =back</diff>
      <filename>lib/Sysadm/Install.pm</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f1600802fc724bfb361158cd8084d0b6606f2d97</id>
    </parent>
  </parents>
  <author>
    <name>mschilli</name>
    <email>github@perlmeister.com</email>
  </author>
  <url>http://github.com/mschilli/sysadm-install-perl/commit/6646c32a04e79857adea8f73224334b43503429c</url>
  <id>6646c32a04e79857adea8f73224334b43503429c</id>
  <committed-date>2009-08-27T18:47:50-07:00</committed-date>
  <authored-date>2009-08-27T18:46:39-07:00</authored-date>
  <message>* slurp() and blurt() now use utf8 mode by default if available
* added utf8_available() and is_utf8_data()
* prepared 0.31 release</message>
  <tree>1cbde5115bf5adc2d51943330f5610b55d20da77</tree>
  <committer>
    <name>mschilli</name>
    <email>github@perlmeister.com</email>
  </committer>
</commit>
