Forum Moderators: coopster

Message Too Old, No Replies

UTF-8 With content-type text/xml problem.

when text/xml is set utf-8 encoding is gone.

         

BlackDex

8:35 am on Jul 21, 2006 (gmt 0)

10+ Year Member



Hello ppl,

I have a big prob.

I have a page which post some input.
This input can be UTF-8 like chinese or other utf-8 chars.
Also i need it to return UTF-8 and it has to be xml.

For some strange reason this isn't working.

Small example.


<?php
header('Content-Type: text/xml; charset=utf-8');
print '<?xml version="1.0" encoding="utf-8"?>'."\n";
print '<test><data>'.$_GET['test'].'</data></test>'."\n";
?>

as GET var fill in something like?test=éëêæ

This will break it..
Only Opera does a good job. Firefox and IE both can't handle it.
If i remove the header Firefox goes well.
IE Still can't handle it.

I Just need simple XML with UTF8 data.

Thx in advance.

encyclo

1:35 am on Jul 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It works perfectly when I test your example code, so there is probably a problem related to your specific setup.

Firstly, is the data really saved in UTF-8? If it is saved as windows-1252 but served as UTF-8, then it will cause an error.

Secondly, what HTTP headers are actually being set by the server when handling the file request? (you can check in Firefox with Ctrl+I).