Hi all, I have searched through the forums and this is very likely a duplicate but I really can't figure this out. I am a newbie at programming and Perl and it is probably beyond me. At the moment I am trying to take some Japanese vocabulary from a MS Access file and then first print it as output to the screen but eventually I want to put it on a website. The first row in my database is: English: 'Ah!' Kana: aa (in hiragana) Kanji: NA (because there is no kanji for this expression) So far I have this:
use DBI; use Encode; use Jcode; my $dbh = DBI->connect('DBI:ODBC:japan','','') or die "Cannot connect: + $DBI::errstr\n"; my $sth = $dbh->prepare('Select English, Kana, Kanji from Vocab') or die "Cannot prepare: $DBI::errstr\n"; $sth->execute or die "Cannot execute: $DBI::errstr\n"; @row = $sth->fetchrow_array(); print("@row\n"); $i=0; foreach $i (@row) { print(getcode($i), "\n"); $i++; } my $ustring = decode( 'ascii1', $row[2] ); print("My ustring is now $ustring\n"); #$dbh->disconnect;
Output1: ---------- Ah! ? NA ascii1 ascii1 ascii1 Unknown encoding 'ascii1' at ... line 22.
So I get a question mark when I try to print the Hiragana and Kanji (for subsequent rows). I used Jcode hoping to see in what form the perl program receives the information. But if feels like I am doing this part wrong. Don't I need to check the data before it enters the perl structure? Even if I did this part right the encoding looks strange as per 'ascii1'. But if I change it to just 'ascii' then my output is this:
Output2: --------- Ah! ? NA ascii1 ascii1 ascii1 My ustring is now 1.
I have no idea how this all works. Can someone please help me use Jcode correctly so I can see how the program receives the data from MS Access and also how to then print out the hiragana or kanji correctly to the screen? Thanks very much for your time.

In reply to 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.