Wisest of monks, Here again I am faced with an undoubtedly easy coding problem that I am struggling helplessly with, so I ask; I need to convert 1 of my variables from EUC to Shift-JIS so it will all appear as readable characters in peoples e-mail clients. It is that simple but I can稚 seem to find a straightforward answer. Here is an example of what I am using.
#!/usr/bin/perl -w use strict; use warnings; use CGI; use Jcode; use DBI; use HTML::Template; use MIME::Base64; require 'jcode.pl'; $| = 1; #unbuffer output $CGI::DISABLE_UPLOADS = 1; # no file uploads - DoS Attack countermeas +ure print "Content-Type: text/html\n\n" ; my $error; # Get the input from the user my $query = new CGI; # set up the database connection my $db = 'test_db'; my $dbhost = '127.0.0.1'; my $dbuser = 'zyxuser'; my $dbpass = 'xyzpass'; my $dbh = DBI->connect("dbi:mysql:$db:$dbhost",$dbuser,$dbpass) + or print qq("COULD NOT INITIALIZE DATABASE $DBI::errstr"); ############################# Start Programing define variables####### +########## my $camp_id = $query->param('camp_id'); my $user_id = $query->param('user_id'); my $email = $query->param('email'); my $name = $query->param('name'); my $zip1 = $query->param('zip1'); my $zip2 = $query->param('zip2'); my $prefect = $query->param('prefect'); my $city = $query->param('city'); my $street = $query->param('street'); my $ADSL = $query->param('ADSL'); my $intrest1 = $query->param('intrest1'); my $intrest2 = $query->param('intrest2'); my $intrest3 = $query->param('intrest3'); my $do_this = $query->param('do_this'); my $do_that = $query->param('do_that'); my $zip = "$zip1-$zip2"; my $intrest = "$intrest1-$intrest2-$intrest3"; my $reply_to = "info\@myhouse.co.jp"; my $subject = q(=?iso-2022-jp A JIS ENCODED subje +ct THAT WORKS==?=);; my $body =q( お世話になっております。 後ほどスタッフよりご連絡させていただきます。); ######## Edited out template part for brevity######### my $mail = qq(To: $email Reply-to: $reply_to From: $reply_to Subject: $subject Content-type: text/plain; charset="ISO-2022-JP" Content-transfer-encoding: 7bit Status: $name 様 $body ); open(MAIL,"| sendmail -t") || die "can't pipe to sendmail"; print MAIL $mail; close(MAIL);
The DB is required to have the text put in EUC. When I try to send the mail with everything EUC clients say it is mojibaki (Japanese unreadable characters). Hence after checking I should be sending the mail in Shift-JIS. The script is simple get text from a form and put the out put to a html template and then send the user a thank you mail with their name in the body and some Japanese text. please bring me enlitenment Hugeus

Readmore tags added by davido per consideration.


In reply to Changing text Encoding EUC Shift-Jis by Hugeusrealus

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.