Skip to content

Instantly share code, notes, and snippets.

@TheAthlete
Last active February 12, 2020 16:01
Show Gist options
  • Save TheAthlete/7b84d0b8f34be4dc9a630fc3dbe43d5f to your computer and use it in GitHub Desktop.
Save TheAthlete/7b84d0b8f34be4dc9a630fc3dbe43d5f to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="windows-1251">
<title>Тест</title>
</head>
<body>
<p>Привет</p>
<p><%= $str %></p>
</body>
</html>
#!/usr/bin/myperl5
use strict;
use warnings;
use Mojo::Template;
use CGI;
use Encode qw/decode encode/;
my $mt = Mojo::Template->new(vars => 1)->encoding('cp1251');
my $CGI = new CGI;
my $str = "вуифывафыва";
$str = decode('cp1251', $str);
print $CGI->header(-type => "text/html; charset=cp1251");
print encode('cp1251', $mt->render_file('foo.mt', {str => $str}));
print "абвгд"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment