Re: UTF-8 &| QuotedPrintable question/problem

From: Date: Wed, 22 Nov 2000 17:06:34 +0000
Subject: Re: UTF-8 &| QuotedPrintable question/problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-26668@lists.php.net to get a copy of this message
Thanks for the responce. I ended up writting a decode header function that works for quoted_printable as well as base 64 encoded headers. Mike ------Begin Code----- function decodeMessageHeader($str) { $len = strlen($str); $in_code = 0; $in_charset = false; $charset = ""; $encoding = ""; $encoded = ""; $decoded = ""; for ($i = 0; $i < $len; $i++) { if ($in_code) { if ($str[$i] == "?") { if ($str[$i+1] == "=") { switch (strtoupper($encoding)) { case 'B': $decoded .= base64_decode($encoded); break; case 'Q': $decoded .= quoted_printable_decode($encoded); break; default: $decoded .= $encoded; } $in_code = false; $encoding = ""; $encoded = ""; $charset = ""; $i++; } else { $in_charset = false; $encoding = $str[$i+1]; $i+=2; } } else if ($in_charset) { $charset .= $str[$i]; } else { $encoded .= $str[$i]; } } else if ($str[$i] == "=" && $str[$i+1] == "?") { $in_code = $i+1; $in_charset = true; $i++; } else { $decoded .= $str[$i]; } } if ($in_code) // This is a failed decode attempt (ie: not an encoded header) $decoded .= substr($str, $in_code - 1, ($len - $in_code)); return ($decoded); } ----- Original Message ----- From: "Sander Pilon" <sander@3dnews.net> To: "Michael Bell" <mike@megaplexus.com>; "PHP Mailing List" <php-general@lists.php.net> Sent: Wednesday, November 22, 2000 10:35 AM Subject: RE: [PHP] UTF-8 &| QuotedPrintable question/problem > Well... you may have to write your own decoding routines. > > Looks to me you have to decode-printable first, and then decode utf8. Since > the content (UTF8 encoded) is encoded as quoted-printable, and then proceed > to decode the content itself (utf8). But this is a wild guess :) > > See - http://www.utf8.com/ for more information about utf8. > > -Sander > > > > -----Original Message----- > > From: Michael Bell [mailto:mike@megaplexus.com] > > Sent: 22 November 2000 16:20 > > To: PHP Mailing List > > Subject: [PHP] UTF-8 &| QuotedPrintable question/problem > > > > > > I just ran across a message from this mailing list that contained the > > headers: > > Content-Type: text/plain; > > charset="UTF-8" > > Content-Transfer-Encoding: quoted-printable > > Subject: =?UTF-8?B?UkU6IFtQSFBdIEhvdyB0byBwYXNzIG9uIGEgdmFyaWFibGUgd2l0?= > > =?UTF-8?B?aCBhIHBhZ2UgcmVxdWVzdA==?= > > > > I'm in the process of writing a web-based email client and am currently > > unable to decode this message. I've tried imap_qprint, > > quoted_printable_decode, utf8_decode as well as combinations of those > > functions but with no luck. Does anyone have a solution to this problem > > (preferable one not revolving around the imap functions)? > > > > Mike > > -------------------------------------------------- > > Michael Bell > > Senior Systems Administrator > > MegaPlexus Corporation > > mike@megaplexus.com > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > >

« previous php.general (#26668) next »