| 
	
 | 
 Posted by SM on 02/06/07 20:29 
Im so confused with the character encoding and charset stuff. 
 
I'm building an XML file in PHP using the DOM and i'm using characters 
like á é í ó ú. I believe those character can be render with the 
charset 'ISO-8859-1' wihtout the need of 'UTF-8', right? 
 
So, how come when i preview it in Firefox, Explorer i get those weird 
characters like ? or ? .... instead of the actual á é í ó ú ? 
 
I've tried using these header in the php file, with no success: 
header ("Content-Type: text/xml; charset=iso-8859-1"); 
 
also when i created the DOM, i've tried using these, with no success: 
$dom = new DOMDocument('1.0', 'iso-8859-1'); 
 
Can someone explain this character encoding stuff 
 
Heres part of my code: 
--------------------------------------------------------- 
<?php 
//set the outpout content type as xml 
header ("Content-Type: text/xml; charset=iso-8859-1"); 
 
//create the DOM document 
$dom = new DOMDocument('1.0'); 
 
// create the root <discography> element 
$discography = $dom->createElement('discography'); 
$dom->appendChild($discography); 
 
.... 
 
 
//create a new <track> and append it to <tracks>, add the <position> 
attribute to <track> 
$track = $dom->createElement('track'); 
$trackText = $dom->createTextNode('Canción'); 
$track->appendChild($trackText); 
$tracks->appendChild($track); 
--------------------------------------------------------- 
 
Thanks 
SM
 
  
Navigation:
[Reply to this message] 
 |