From: Jan "Yenya" Kasprzak Date: Thu, 21 Apr 2022 14:29:10 +0000 (+0200) Subject: Handle UTF-8 gracefully X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=paste.git;a=commitdiff_plain;h=61bea8f9e2f6ef84c0477fd49cf1767890e88826 Handle UTF-8 gracefully --- diff --git a/paste.pl b/paste.pl index 8103a94..d8b628c 100755 --- a/paste.pl +++ b/paste.pl @@ -58,7 +58,9 @@ get '/.' $c->stash(mtime => POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime($stat->mtime))); - $c->stash(file_content => $file->slurp); + my $content = $file->slurp; + $content = Encode::decode('utf-8', $content); + $c->stash(file_content => $content); my $lang = $c->param('ext'); $c->stash(language => "language-$lang");