Is this the right way to do it?



I appreciate this is not a PHP specific question, but I am using PHP to do it, and you're a knowledgeable bunch, so here goes.

I am writing a custom email client to integrate into my application. I use the various imap functions to get message bodies etc.

I am using ajax (xajax to be precise) to display the message body - I populate a div with it.

I can retrieve the character encoding of the message body by using the imap_bodystruct() function.

I then use that character encoding in the header of the ajax output in the content type before outputting the message to the browser.

So far it seems to work fine. Is this the best way to do it? Or would I be better off changing the message body to a different charset?
.