(keitai-l) Re: Fun with Base64 Decoding

From: Paul Lester <paul_lester_at_lincmedia.co.jp>
Date: 10/25/01
Message-ID: <3BD7DE72.B78042FB@lincmedia.co.jp>
    I had nightmares with these issues about 6 months ago (but I can't help
too much since I didn't use perl at all).

    Here's some stuff I kind of learned.

    I didn't realize that ISO-2022-JP is the standard for email and not
SJIS (which according to a book I read is a subset or something of ISO-2022-JP)
or something like that.  All the DoCoMo phones I used didn't care if I
used SJIS or not but if you do things for J-Phone's and AU's some of them
can't decode SJIS from the base-64 stuff but they can if you use
ISO-2022-JP instead.

    As for all the base-64 encoding, I was using Java and there already was
 a class handling it, so I can't help with the internals there.

{
import com.sun.mail.util.BASE64EncoderStream;
import com.sun.mail.util.BASE64DecoderStream;
}

    As for your original problem,  I have never explicitly used EUC but I assume
you should test your stuff with Shift-JIS instead of EUC.  They are 2
different encodings after all and just because one works doesn't mean
that the other will.  (And even if it does "work" if your working environment
can't display Shift-JIS but can display EUC it could explain your problem).

    Hopefully your problem is as simple as changing how your environment reads
ShiftJIS.  Try cutting and pasting some SJIS in from another program to your output window.

    I hope this helps someone a little someday.

Renfield Kuroda wrote:

> Looks like he already did that:
>
> > ### ... detect a Base64 encoded line .. ###
> > ###   strip control characters, leaving this: GyRCRnxLXDhsGyhC ###
>
> So I'm guessing the issue is one of display. After base64 decoding, you will
> have a string of iso-2022-jp Japanese which will most likely NOT display
> correctly unless you've got a properly configured xterm or something. So it
> probably was working but unconfirmed as it displayed as gibberish.
>
> r e n
>
> "Brock, Gavin [IT]" wrote:
>
> > Nearly, you need to remove the 'padding' (as the error said)...
> >
> > my $line = '=?ISO-2022-JP?B?GyRCRnxLXDhsGyhC?=';
> > my $head = quotemeta('=?ISO-2022-JP?B?'); # Save working this out by hand!!
> > $line =~ s/^$pat//; # Trim header
> > print decode_base64($line);
> >
> > Works for me!!
> >
> > Maybe this should be patched into Jcode.pm. I'll try if I have time.
>
> [ excessive quoting removed by moderator ]
>
> [ Need archives? How to unsubscribe? http://www.appelsiini.net/keitai-l/ ]

--
*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=
Paul Bryan Lester
Layer-8 Technologies Inc
LincMEDIA Group
QA ENGINEER/Programmer etc etc
EMAIL: paul.lester@L8tech.com
       paul_lester@lincmedia.co.jp
--
http://myc.thetamusic.com/framesets/myc.html
http://www.thetamusic.com/
http://www.lincmedia.co.jp/
http://www.chakumatic.com/
http://www.daijob.com/

personal homepage: http://pbl1.tripod.com/
personal EMAIL: pbl1@cornell.edu
*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=



[ Need archives? How to unsubscribe? http://www.appelsiini.net/keitai-l/ ]
Received on Thu Oct 25 12:33:37 2001