Aaagh I spoke too soon. Have just gone through the pleasure but learning experience :) of installing Apache with Perl supported and lo and behold those beautiful question marks are still there when outputting to Firefox.

mysql_enable_utf8 sounds very promising...so can you tell me how to turn it on in the code that I was using before?

I am hoping you are going to say something other than:

... mysql_enable_utf8; ....

because I tried that and am still getting question marks.

Although thankfully it mentions in the doco that you have to use it in your connect statement. But not sure where it would go.

Also does this mean I should be using something like:

my $dbh = DBD->connect('DBD<stuff here>:ODBC:japmysql','','')
or should it be left as:
my $dbh = DBI->connect('DBI:ODBC:japmysql','','')

Update:
I managed to find an example on the web of how to do it so my code now looks like this:

#!C:/Perl/bin/perl use DBI; use DBD::mysql; use CGI qw/:standard :html3/; use CGI::Carp qw(fatalsToBrowser); my $query = CGI -> new; use Encode "encode"; sub U2Entity { return '&#x'.unpack("H*", encode("ucs2be", shift)).';'; } sub Any2Hex { return unpack("H*", shift); } print header(-charset=>'utf-8'); print "<html><body>\n"; my $dbh = DBI->connect('DBI:ODBC:japmysql','','', {mysql_enable_utf8=> +1}) or die "Cannot connect: $DBI::errstr\n"; $dbh->{mysql_enable_utf8} or die "couldn't init mysql_enable_utf8"; my $sth = $dbh->prepare('Select English, Kana, Kanji from Vocab') or die("Couldn't prepare"); $sth->execute or die ("Could not execute SQL statement."); if($sth->rows == 0) { print "No information."; } else { print "<table border=1>\n"; while( $resptr = $sth->fetchrow_hashref() ) { print "<tr>"; print "<td>" . $resptr->{"English"}; print "<td>" . $resptr->{"Kana"}; print "<td>" . $resptr->{"Kanji"}; print "\n"; } print "</table>\n"; } print "</body></html>\n"; $dbh->disconnect;
Unfortunately it dies at:
$dbh->{mysql_enable_utf8} or die "couldn't init mysql_enable_utf8";
Any ideas? By the way, where do subs usually go? Is it at the bottom of the file or at the top? Thanks again Almut.

In reply to Re^6: MS Access Input -> Japanese Output by Zettai
in thread MS Access Input -> Japanese Output by Zettai

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.