summaryrefslogtreecommitdiff
path: root/fml/lib/FML/MIME.pm
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-02-18 11:05:49 +0000
committerfukachan <fukachan>2001-02-18 11:05:49 +0000
commit52c691e2bd0a65525f74a6c4d8a7b0d5ddf465ee (patch)
tree2b72f621b9ab3b7499b0d45741c0b864c0ca0c3b /fml/lib/FML/MIME.pm
parentaaa11f6cce0a51826cf6cccb03d6b65f4911e6f7 (diff)
downloadfml8-52c691e2bd0a65525f74a6c4d8a7b0d5ddf465ee.tar.gz
fml8-52c691e2bd0a65525f74a6c4d8a7b0d5ddf465ee.tar.bz2
fml8-52c691e2bd0a65525f74a6c4d8a7b0d5ddf465ee.zip
write up mime_{decode,encode}_string()
Diffstat (limited to 'fml/lib/FML/MIME.pm')
-rw-r--r--fml/lib/FML/MIME.pm37
1 files changed, 26 insertions, 11 deletions
diff --git a/fml/lib/FML/MIME.pm b/fml/lib/FML/MIME.pm
index 03417abe..0f9f6747 100644
--- a/fml/lib/FML/MIME.pm
+++ b/fml/lib/FML/MIME.pm
@@ -13,30 +13,45 @@ use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK);
use Carp;
+
require Exporter;
-@ISA = qw(Exporter);
+@ISA = qw(Exporter);
+@EXPORT_OK = qw(mime_decode_string mime_encode_string);
-sub new
+sub mime_decode_string
{
-my ($self) = @_;
-my ($type) = ref($self) || $self;
-my $me = {};
-return bless $me, $type;
-}
+ my ($str, $options) = @_;
+ my $charset = $options->{ 'charset' } || 'euc-japan';
+ if ($charset eq 'euc-japan') {
+ use Jcode;
+ use MIME::Base64;
-sub mime_decode_string
-{
- my ($str, $type) = @_;
+ if ($str =~ /=\?ISO\-2022\-JP\?B\?(\S+\=*)\?=/i) {
+ $str =~ s/=\?ISO\-2022\-JP\?B\?(\S+\=*)\?=/decode_base64($1)/gie;
+ }
+
+ if ($str =~ /=\?ISO\-2022\-JP\?B\?(\S+\=*)\?=/i) {
+ $str =~ s/=\?ISO\-2022\-JP\?B\?(\S+\=*)\?=/decode_base64($1)/gie;
+ }
+ }
+ &Jcode::convert(\$str, 'euc');
+ $str;
}
sub mime_encode_string
{
- my ($str, $type) = @_;
+ my ($str, $options) = @_;
+ my $charset = $options->{ 'charset' } || 'iso-2022-jp';
+
+ &Jcode::convert(\$str, 'jis');
+ $str = encode_base64($str);
+ $str =~ s/\n$//;
+ return '=?'. $charset . '?B?' . $str . '?=';
}