FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Encoding Problems
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Encoding Problems [message #186334] Wed, 02 July 2014 15:53 Go to previous message
stef_204 is currently offline  stef_204
Messages: 1
Registered: July 2014
Karma:
Junior Member
Hi,

Newbie at php; please bear with me.

I am trying to use a script which basically creates an xml feed for email
messages found in an IMAP account; one can then either subscribe to feed
via an rss reader/aggregator or use browser to read html page.

Here is the script: <http://linuxtrove.com/wp/?p=209>
(imap2rss.php)

My problem: almost all of the messages (emails) show garbled text, I
believe due to encoding problems.

Here is a picture of how it looks both using a browser like Firefox or an
rss news feed reader.

<http://imagebin.org/314843>

The emails are legible using an email client but not via the xml and html
page created by php script.

This is what I first thought:
It looks like the emails are plain text but using utf-8 and when the feed
is created (and the html page); there is no recognition of the encoding
and it all gets garbled, etc.

Server (shared) is running PHP 5.2.17 on Apache/2.2.22.
PHP config --> default_charset: iso-8859-1

I cannot change the config on the server since it is shared hosting but I
can certainly modify the script to hopefully fix this issue.

I have tried to insert in the script:
ini_set( 'default_charset', 'UTF-8' );
htmlentities( $string, ENT_COMPAT, "UTF-8" );
header('Content-type: text/plain; charset=utf-8');
but no joy.

I have also tried to add to .htaccess IndexOptions +Charset=UTF-8 No joy
there either.

I could be completely wrong about the utf-8 issue; and perhaps it has
more something to do with decoding base64 in general.

This is what I now think is the problem, more specifically:
I have just tried a base64 online decoder and pasted the garbled text in
it and used the "decode" online feature, and the result is perfectly
legible once decoded, whether I choose utf-8 or ascii as charset (but I
should use utf-8).

So, looks like the feed is "echoed" or "printed" in base64 format....
It doesn't look like charset is the problem but decoding base64.

I can see the base64_decode function here
<http://www.php.net/manual/en/function.base64-decode.php>
but not sure if this is the right way to go about this; or how to apply
it in this script.

I am going about this fairly blind, I must say, and doing trial and error
which is just wrong....

Again, this is the script.
<http://linuxtrove.com/wp/?p=209>

Any pointers?

Tx.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Help with Pear Soap Client to weather service
Next Topic: Resolved: Generating "download" pages
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Apr 28 02:09:38 GMT 2024

Total time taken to generate the page: 0.04420 seconds