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

From: Date: Fri, 21 Jul 2006 14:38:48 +0000
Subject: Re: UTF-8 With content-type text/xml problem.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-239679@lists.php.net to get a copy of this message
I'm somewhat new to this stuff as well, so take this with a grain of salt... Someone else was hinting at this, but more directly, try running utf8_encode() on whatever part of your data that requires utf8 encoding. In the case of your example, you could just utf8_encode the test get variable. To extend your example a little: header('Content-Type: text/xml; charset=utf-8'); print "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; print "<test>\n"; print " <origEncoding>" . mb_detect_encoding($_GET['test']) . "</origEncoding>\n"; print " <utf8data1>" . utf8_encode($_GET['test']) . "</utf8data1>\n"; print " <utf8data2>" . mb_convert_encoding($_GET['test'],'UTF-8') . "</utf8data2>\n"; print "</test>\n"; I tried this with: 會意字/会意字, which I stole from Wikipedia. I don't have a clue what it means. jon Mathijs wrote:
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 Code: <?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. PS: This also breaks database saving, it doesn't save correct. And i have mbstring installed. Thx in advance. --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 0629-1, 07/19/2006 Tested on: 7/21/2006 11:17:03 AM avast! - copyright (c) 1988-2006 ALWIL Software. http://www.avast.com


« previous php.general (#239679) next »