bitfactory
asked on
Getting charset of web page and setting output charset encoding.
Hi,
I'm looking for a solution to problem with getting and setting the character encoding.
The problem:
I have a code that outputs some text. This code is included in pages where I do not have the control over character encoding. My text comes from PHP as UTF-8 by default.
What I need is: get the character encoding of the "master" page and converting the "myscript" output text to the character set of the master page.
no mbstring extension available ...
Thanks
I'm looking for a solution to problem with getting and setting the character encoding.
The problem:
I have a code that outputs some text. This code is included in pages where I do not have the control over character encoding. My text comes from PHP as UTF-8 by default.
What I need is: get the character encoding of the "master" page and converting the "myscript" output text to the character set of the master page.
no mbstring extension available ...
Thanks
ASKER
sorry I can't access that link...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW, if you need a simple ISO to UTF8 conversion, you may also try utf8_encode, if XML extension is available for you.
Sorry, that article is not a case, the performance will drop dead if your script will try to check for an encoding by fetching the page output.
You'll be better to determine the "master" encoding manually. Or if your provide an include for third parties, let them choose output encoding by providing your script a charset argument via GET or something like.
Sorry, that article is not a case, the performance will drop dead if your script will try to check for an encoding by fetching the page output.
You'll be better to determine the "master" encoding manually. Or if your provide an include for third parties, let them choose output encoding by providing your script a charset argument via GET or something like.
ASKER
Thanks for your comments. I have tried iconv before I posted here, but couldn't find the possibility to get the master web site charset ... Anyway, I have been thinking a lot about this and in fact there's no real solution how to get the encoding of the page where the PHP is run, as it's a server side execution of the script and there I have no access to what will be the output when it's done.
One solution would be getting the file contents that is currently being processed, but there would be an infinite loop...
Anyway thanks, for help I'll give you points.
One solution would be getting the file contents that is currently being processed, but there would be an infinite loop...
Anyway thanks, for help I'll give you points.
ASKER
Thanks for your comments. I have tried iconv before I posted here, but couldn't find the possibility to get the master web site charset ... Anyway, I have been thinking a lot about this and in fact there's no real solution how to get the encoding of the page where the PHP is run, as it's a server side execution of the script and there I have no access to what will be the output when it's done.
One solution would be getting the file contents that is currently being processed, but there would be an infinite loop...
Anyway thanks, for help I'll give you points.
One solution would be getting the file contents that is currently being processed, but there would be an infinite loop...
Anyway thanks, for help I'll give you points.
You're welcome.
Simply check "character encoding" in your browser with your own eyes to know master page's charset. As I said, checking it with script by fetching the output page via http will bring the performance to the knees.
Simply check "character encoding" in your browser with your own eyes to know master page's charset. As I said, checking it with script by fetching the output page via http will bring the performance to the knees.
http://nadeausoftware.com/articles/2007/06/php_tip_how_get_web_page_content_type