Last active
March 28, 2020 17:50
-
-
Save ferki/cdc05ad868100ac57eb194f836edbb8a to your computer and use it in GitHub Desktop.
file encoding issue RexOps/Rex#1274
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
open my $utf8, '>', '/tmp/use_utf8file'; | |
print $utf8 'Daniel Böhmer'; | |
close $utf8; | |
no utf8; | |
open my $not_utf8, '>', '/tmp/no_utf8file'; | |
print $not_utf8 'Daniel Böhmer'; | |
close $not_utf8; | |
# check results with this command: | |
# file --mime-encoding *_utf8file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Rex; | |
task 'files', sub { | |
# utf8 disabled | |
say 'disabling utf8 pragma'; | |
no utf8; | |
my $file = '/tmp/test'; | |
file $file, content => 'Daniel Böhmer'; | |
say 'file content:'; | |
say cat $file; | |
say 'encoding:'; | |
say run "file $file"; | |
say '-' x 10; | |
# utf8 enabled | |
say 'enabling utf8 pragma'; | |
use utf8; | |
my $file = '/tmp/test'; | |
file $file, content => 'Daniel Böhmer'; | |
say 'file content:'; | |
say cat $file; | |
say 'encoding:'; | |
say run "file $file"; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment