This should be the correct answer, but I don't think the string is correctly encoded. This: use Encode qw(decode);
my $str = 'username, A Ne=?UTF-16?B?dwAgAEMAcgBlAGQAaQB0ACAAQwBhAHIAZA
+AgAEMAbwB1AGwAZAAgAEIAZQAgAEgAZQBhAGQAZQBkACAAWQBvAHUAcgAgAFcAYQB5AA=
+=?=';
my $chr = decode('MIME-Header', $str);
print "$chr\n";
Gets me: UTF-16:Unrecognised BOM 7700 at /.../Encode/MIME/Header.pm line 81.
While this: use MIME::Base64;
my $cstr = 'dwAgAEMAcgBlAGQAaQB0ACAAQwBhAHIAZAAgAEMAbwB1AGwAZAAgAEIAZQ
+AgAEgAZQBhAGQAZQBkACAAWQBvAHUAcgAgAFcAYQB5AA';
my $chk = decode_base64($cstr);
print "$chk\n";
Gets me: w Credit Card Could Be Headed Your Way
So the part that is supposed to be UTF-16 appears to be just base64 encoded.
UPDATE: And if you change 'UTF-16' in the first part to 'UTF-8', then it is correctly decoded without error.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|