Skip to content

Instantly share code, notes, and snippets.

@dynax60
Created August 20, 2010 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dynax60/540209 to your computer and use it in GitHub Desktop.
Save dynax60/540209 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use Mojolicious::Lite;
use Mojo::ByteStream 'b';
use Mojo::JSON;
use utf8;
...
our $dbh = DBI->connect("dbi:mysql:dbname=cli;host=localhost",
'user', 'pass',
{ PrintError => 0, RaiseError => 1 });
$dbh->do("SET NAMES utf8");
$dbh->do("SET CHARACTER SET utf8");
$dbh->do("SET character_set_connection=utf8");
$dbh->do("SET character_set_client=utf8");
$dbh->do("SET character_set_server=utf8");
$dbh->do("SET character_set_results=utf8");
get '/' => sub {
...
my $rows = $dbh->selectall_arrayref(q{
select title from contract where id = ?
}, {}, $id);
grep { grep { $_ = b($_)->decode('UTF-8') } @$_ } grep { $_ } @$rows ;
$self->render( 'rows' => $rows );
}
@dynax60
Copy link
Author

dynax60 commented Aug 20, 2010

Если обернуть запросик в b("..")->decode('UTF-8') рендерится нормально.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment