Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Japanese in Perl on Linux
- Date: 12 May 2004 14:30:52 -0700
- From: Marjan Parsa <marjanp@example.com>
- Subject: Re: [tlug] Japanese in Perl on Linux
- References: <1084328057.18154.17.camel@example.com>
- User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)
Blomberg David <dblomber@example.com> writes: > I am using perl to send an email it works except that Japanese text come > out as question marks. > > could any perl monger out there let me in on how I am doing this wrong? > ------first version---------------------------------- > print MAIL "$BIT@example.com%Q%9%o!<%I>pJs(B"; > > (first version output is just question marks) > ------Second version---------------------------------- > $temp = MIME::Base64::encode("$BIT@example.com%Q%9%o!<%I>pJs(B"); > chomp($temp); > print MAIL "=?ISO-2022-JP?B?$temp?=\n"; > > (this one I get the string > =?ISO-2022-JP?B?Pz8/Pz8/Pz8/?= > mime encoded Japanese text as best I can tell) > ----------------------------------------------------- I'm assuming you'd like to B encode this text for a mail header. In which case, the following works for me (note that the file encoding is UTF-8): $temp = MIME::Base64::encode("$BIT@example.com%Q%9%o!<%I>pJs(B"); chomp($temp); print "=?UTF-8?B?$temp?=\n"; It outputs: =?UTF-8?B?5LiN5q2j44OR44K544Ov44O844OJ5oOF5aCx?= I tested this in the Subject of an email with gnus mail reader and it displays correctly. I'm using Perl 5.6.1 (which may behave differently than Perl 5.8). I can get this working with ISO-2022-JP as long as I store the data in a separate file (ISO-2022-JP encoded) and read it in to B encode it. Here's what I get in that case. =?ISO-2022-JP?B?GyRCSVRANSVRJTklbyE8JUk+cEpzGyhCCg==?= If you want to put the text in the body of the email, then you don't need to encode it as long as you set the Content-Type to match the encoding of the text. Content-Type: text/plain; charset=ISO-2022-JP This would work as long as your data is in ISO-2022-JP. Since ISO-2022-JP is 7 bit, you don't need to set Content-Transfer-Encoding (it defaults to 7bit). But if you're using UTF-8 for example, then it would have to be set to 8bit. You can use iconv to convert between encodings. To convert a file from EUC-JP to ISO-2022-JP: iconv -f euc-jp -t iso-2022-jp <filename> Hope this helps. Marjan
- References:
- [tlug] Japanese in Perl on Linux
- From: Blomberg David
Home | Main Index | Thread Index
- Prev by Date: [tlug] Seen in this week's GWN
- Next by Date: Re: [tlug] (OT) Japanese cell-phone-mail-system
- Previous by thread: Re: [tlug] Japanese in Perl on Linux
- Next by thread: [tlug] (OT) Japanese cell-phone-mail-system
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links