1

I've a problem with koi8r charset with mimeDecode,

As an example:

Subject: =?KOI8-R?B?8NLJ18XUIQ==?= From: =?KOI8-R?B?4czFy9PBzsTSIPfPzMvP1w==?=

Becomes:

Subject: п÷я─п╦п╡п╣я┌! From: Александр Волков

It should be as follows,

Subject: Привет! From: Александр Волков

So the exact problem is

        if (is_string($this->_decode_headers)) {
            $conv = @iconv($charset, $this->_decode_headers, $text);
            $text = ($conv === false) ? $text : $conv;
        }

Thank you.

UPDATE Solved, the problem was email headers were saved to db in other charset.

alex volkow
  • 129
  • 3
  • 13

1 Answers1

5

Don't you want to use mb_decode_mimeheader ?

iconv translates encoded strings, here your string is only ascii.

mb_internal_encoding("UTF-8");
$string = "=?KOI8-R?B?8NLJ18XUIQ==?=";
$conv = mb_decode_mimeheader($string);

This will work provided that you're sending utf-8 encoded string of course, otherwise you have to adapt the first command

Immae
  • 313
  • 1
  • 2
  • 6
  • Some explanation: There are three "encoding" here in this situation : 1) The encoding of the string is ascii, because it is the only one accepted in header of emails. 2) The strings "contains" KOI8-R chars (cyrillic), encoded in mime encoding (it is a way to write other encoding chars with only ascii) 3) the output `$conv` contains UTF-8 chars (by the choice of `mb_internal_encoding`) – Immae Mar 24 '12 at 22:22
  • Hi, I'm sorry but I need it to do inside of function _decodeHeader [link](http://svn.php.net/viewvc/pear/packages/Mail_mimeDecode/trunk/Mail/mimeDecode.php?view=co) – alex volkow Mar 24 '12 at 22:33