Jump to content

utf-7 errors


surion

Recommended Posts

if i use this code:

 

function decode($data,$code)

if(!$code){return imap_utf7_decode($data);}

if($code==0){return imap_utf7_decode($data);}

if($code==1){return imap_utf8($data);}

if($code==2){return ($data);}

if($code==3){return imap_base64($data);}

if($code==4){return imap_qprint(str_replace($myqprinta,$myqprintb,($data)));}

if($code==5){return ($data);}

}

 

 

 

i get next error:

 

<br />

<b>Warning</b>:  imap_utf7_decode() [<a href='function.imap-utf7-decode'>function.imap-utf7-decode</a>]: Invalid modified UTF-7 character: `

' in <b>/home/www/www.t2t.be/html/ontwikkeling/0-3-1/mailclient/downloadattachment.php</b> on line <b>82</b><br />

 

 

Line 82, is the first one in the function, any ideas? it used to work, i haven't modified it in any way lately.

 

Link to comment
https://forums.phpfreaks.com/topic/38281-utf-7-errors/
Share on other sites

nope, it happens with all of them, when i try to download an attachment

 

*edit*

 

this is the code where the function is called (but as i said before, it used to work, and it hasn't been modified lately):

 

$struct = @imap_fetchstructure ($stream, $msgid);

$coding = $struct->parts[$part_no]->encoding;

$message = imap_fetchbody ($stream, $msgid, ($part_no + 1));

$message = decode($message,$coding);

Link to comment
https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-183452
Share on other sites

uh oh, very weird

 

now i replaced "return imap_utf7_decode($data);"

with "return mb_convert_encoding( $data, "ISO_8859-1", "UTF7-IMAP" );"

 

and i get this:

 

  ------=_Part_41610_32609836.1171314044371

Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Content-Transfer-Encoding: 7bit

Content-Disposition: inline

 

test

 

------=_Part_41610_32609836.1171314044371

Content-Type: text/html; charset=ISO-8859-1

Content-Transfer-Encoding: 7bit

Content-Disposition: inline

 

test

 

------=_Part_41610_32609836.1171314044371--

 

Link to comment
https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-183483
Share on other sites

i hope its not forbidden here to BUMP ones own messages?

still having the same problems, i just left the problem for what it was and went on with some other programming for the same platform, but now that i m about to do the finishing touches, this realy should get fixed, still nobody an idea?

Link to comment
https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-185423
Share on other sites

What is in $data?

 

P.S. Use a switch statement instead of multiple ifs.

 

 

here the function gets called: (also see a few posts ago)

 

$message = imap_fetchbody ($stream, $msgid, ($part_no + 1));

$message = decode($message,$coding);

 

So, the $data value in the function is the $message one here. it can be a file of any kind, its all about attachments in a mail

 

& yea i could use a switch in stead of the if's, but that can't cause the problem i think, since it used to work before

 

 

Link to comment
https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-185443
Share on other sites

Do you know for sure that the file is valid UTF-7?

Does mb_convert_encoding work if you use "ISO-8859-1" instead of "ISO_8859-1"?

I didn't read this in its entirety, but the last line mentions "This bug still exists in PHP 5.1.4 under GNU/Linux." Maybe it's related.

Link to comment
https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-185459
Share on other sites

Do you know for sure that the file is valid UTF-7?

Does mb_convert_encoding work if you use "ISO-8859-1" instead of "ISO_8859-1"?

I didn't read this in its entirety, but the last line mentions "This bug still exists in PHP 5.1.4 under GNU/Linux." Maybe it's related.

 

no, actualy i don't know, thats why there is that if structure, with the next part of code:

 

$coding = $struct->parts[$part_no]->encoding;

 

i get the encoding type (it returns a value 0 to 5)

and gets send to the function where it arrives as $code

 

code 0 means imap_utf7

code 1 means utf8

enz enz

 

untill

code 5 wich means there is no encoding

 

since i get that error on that line 82 it means that code had value 0 and that it should be utf7 (found a table with those value somewhere, i ll post them here if i find it back)

Link to comment
https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-185590
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.