<div dir="ltr">I am beginner in Dancer. Help me please.<br><br>I am having database on Oracle 10g. Web server and Oracle Client is working under openSUSE 12.3. DB data encoding is Windows-1251 (I can't change this).<br>
I have set system environment variable NLS_LANG = AMARICAN_AMERICA.CL8MSWIN1251. I am constantly workin with Perl and Oracle DB and always do so.<br>My system console character set in openSUSE is UTF-8.<br><br>But after select I get the data in a double byte character set (I looked in log). And this is not UTF-8. Why? What am I doing wrong?<div>
</div><div><span id="result_box" class="" lang="en"><span class=""><br><br></span></span></div><div><span id="result_box" class="" lang="en"><span class="">My config.yml:<br><br><span style="font-family:courier new,monospace">appname: "AAA"<br>
server: "172.0.0.244"<br>port: 8008<br>environment:"development"<br>layout: "main"<br>charset: "UTF-8"<br>template: "simple"<br>logger: "file"<br>
serializer: "JSON"<br>plugins:<br> Database:<br> driver: "Oracle"<br> host: "172.0.0.250"<br> sid: "DEVDB"<br> username: "A"<br>
password: "AAA"<br> log_queries: 1<br> auto_utf8: 0<br> dbi_params:<br> AutoCommit: 1<br> RaiseError: 1<br> PrintError: 0<br> PrintWarn: 0</span><br>
<br></span></span></div><div> <br></div><div>My simple application for test:<br><span style="font-family:courier new,monospace"><br>#!/usr/bin/perl<br><br>use v5.16;<br>use utf8;<br>use Dancer;<br>use Dancer::Plugin::Database;<br>
<br>get '/' => sub { <br> var time => scalar(localtime);<br> my $tst_set = database->selectcol_arrayref('SELECT label FROM et_list WHERE tbl=1 AND gr=3');<br> my $S;<br> foreach (@{$tst_set}) {<br>
my $s = $_; <br> $S.= "$s<br>";<br> }<br> template '<a href="http://test.tt">test.tt</a>', { test => $S };<br>};<br>dance;</span><br><br></div><div><span id="result_box" class="" lang="en"><span class="">In the browser,</span> <span class="">I see a</span> <span class="">clumsy</span> <span class=""></span></span><span id="result_box" class="" lang="en"><span class=""><span id="result_box" class="" lang="en"><span class="">unreadable </span></span>text. :-(<br>
</span></span></div><div>I have tried add - <span style="font-family:courier new,monospace">Encode::from_to($s, 'cp-1251', 'utf-8'); </span>- another <span id="result_box" class="" lang="en"><span class="">clumsy</span> </span><span id="result_box" class="" lang="en"><span id="result_box" class="" lang="en"><span class="">unreadable</span></span> <span class="">text<br>
</span></span></div><div><span id="result_box" class="" lang="en"><span class="">Encoding in the HTML set as UTF-8. <br><br></span></span></div><div><span id="result_box" class="" lang="en"><span class="">I have wrote simple perl script for test and run it from openSUSE system console:<br>
<br><span style="font-family:courier new,monospace">#!Perl<br>use v5.16;<br>use strict;<br>use DBI;<br><br>my $DB_Server ='172.0.0.250';<br>my $DB_SID ='DEVDB';<br>my $DB_User ='A';<br>my $DB_Pass ='AAA';<br>
<br>my $dbh;<br>eval{<br> $dbh=DBI->connect("dbi:Oracle:host=$DB_Server;sid=$DB_SID",<br> $DB_User, $DB_Pass, {<br> AutoCommit =>0,<br> RaiseError =>1,<br>
PrintError =>0,<br> PrintWarn =>0<br> })<br>}; if ($@) {<br> die "Connection error: $@"<br>}<br>my $tst_set = $dbh->selectcol_arrayref(</span></span></span><span id="result_box" class="" lang="en"><span class=""><span style="font-family:courier new,monospace">'SELECT label FROM et_list WHERE tbl=1 AND gr=3');<br>
<br>say join("\n", @{$tst_set});<br><br>$dbh->disconnect;</span><br><br></span></span></div><div><span id="result_box" class="" lang="en"><span class="">An this work. All OK<br><br></span></span></div><div><span id="result_box" class="" lang="en"><span class="">I nothing understand. Help me please.<br>
<br></span></span></div><div><span id="result_box" class="" lang="en"><span class="">PS. I have tried run this Dancer application under Windows-7 ( Dancer 1). It's working OK<br></span></span></div><div><span id="result_box" class="" lang="en"><span class=""><br>
</span></span></div><div><span id="result_box" class="" lang="en"><span class=""><br><br></span></span></div><div><br></div></div>