surion Posted February 13, 2007 Share Posted February 13, 2007 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 More sharing options...
btherl Posted February 13, 2007 Share Posted February 13, 2007 Is the error from a particular email? Maybe the email says it has one encoding, but it really has another. Link to comment https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-183450 Share on other sites More sharing options...
surion Posted February 13, 2007 Author Share Posted February 13, 2007 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 More sharing options...
surion Posted February 13, 2007 Author Share Posted February 13, 2007 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 More sharing options...
surion Posted February 13, 2007 Author Share Posted February 13, 2007 and when i use return iconv("UTF7-IMAP", "ISO_8859-1", $data); i get no value returned Link to comment https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-183485 Share on other sites More sharing options...
surion Posted February 15, 2007 Author Share Posted February 15, 2007 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 More sharing options...
effigy Posted February 15, 2007 Share Posted February 15, 2007 What is in $data? P.S. Use a switch statement instead of multiple ifs. Link to comment https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-185429 Share on other sites More sharing options...
surion Posted February 15, 2007 Author Share Posted February 15, 2007 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 More sharing options...
effigy Posted February 15, 2007 Share Posted February 15, 2007 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 More sharing options...
surion Posted February 15, 2007 Author Share Posted February 15, 2007 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 More sharing options...
surion Posted February 15, 2007 Author Share Posted February 15, 2007 here they are: http://be.php.net/imap_fetchstructure table 3 seems like i m wrong with what a returned "5" would mean, but that is not a problem atm Link to comment https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-185591 Share on other sites More sharing options...
effigy Posted February 15, 2007 Share Posted February 15, 2007 Maybe it's not being detected properly. See if mb_detect_encoding tells you anything different (non-UTF7). Link to comment https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-185635 Share on other sites More sharing options...
surion Posted February 15, 2007 Author Share Posted February 15, 2007 hmmm, that would mean there is something wrong in this: $coding = $struct->parts[$part_no]->encoding; guess im gonna check that 1st thing 2morrow, good hint, i m gonna keep ya up to date Link to comment https://forums.phpfreaks.com/topic/38281-utf-7-errors/#findComment-185637 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.