Changeset 718

Show
Ignore:
Timestamp:
06/08/07 20:18:24 (1 year ago)
Author:
schst
Message:

Fixed bug #64: German Umlauts in XMLWriter

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/xml/stubDomXMLStreamWriter.php

    r678 r718  
    111111     */ 
    112112    public function writeCData($cdata) { 
    113         $cdataNode = $this->doc->createCDATASection($cdata); 
     113        $cdataNode = $this->doc->createCDATASection(utf8_encode($cdata)); 
    114114        $this->addToDom($cdataNode); 
    115115    } 
     
    121121     */ 
    122122    public function writeComment($comment) { 
    123         $commentNode = $this->doc->createComment($comment); 
     123        $commentNode = $this->doc->createComment(utf8_encode($comment)); 
    124124        $this->addToDom($commentNode); 
    125125    } 
     
    132132     */ 
    133133    public function writeProcessingInstruction($target, $data = '') { 
    134         $piNode = $this->doc->createProcessingInstruction($target, $data); 
     134        $piNode = $this->doc->createProcessingInstruction($target, utf8_encode($data)); 
    135135        $this->addToDom($piNode); 
    136136    } 
     
    155155    public function writeAttribute($attributeName, $attributeValue) { 
    156156        $currentElement = end($this->elementStack); 
    157         $currentElement->setAttribute($attributeName, $attributeValue); 
     157        $currentElement->setAttribute($attributeName, utf8_encode($attributeValue)); 
    158158    } 
    159159 
  • trunk/src/test/php/net/stubbles/xml/stubXMLSerializerTestCase.php

    r717 r718  
    205205        return null; 
    206206    } 
     207} 
     208 
     209/** 
     210 * Class to test german umlaut properties 
     211 * 
     212 * @XMLTag(tagName='test') 
     213 */ 
     214class XMLSerializerUmlautTest { 
     215 
     216    /** 
     217     * test property 
     218     * 
     219     * @var string 
     220     * @XMLTag(tagName='foo') 
     221     */ 
     222    public $foo = 'Hähnchen'; 
     223 
     224    /** 
     225     * test property 
     226     * 
     227     * @var string 
     228     * @XMLAttribute(attributeName='bar') 
     229     */ 
     230    public $ba = 'Hühnchen'; 
     231 
    207232} 
    208233 
     
    396421 
    397422    /** 
     423     * Test serializing an object with umlauts 
     424     */ 
     425    public function testObjectUmlauts() { 
     426        $writer = new stubDomXMLStreamWriter(); 
     427        $obj = new XMLSerializerUmlautTest(); 
     428        $this->serializer->serialize($obj, $writer); 
     429        $this->assertEqual('<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n" . '<test bar="Hühnchen"><foo>Hähnchen</foo></test>', $writer->asXML()); 
     430    } 
     431 
     432    /** 
    398433     * Test serializing an object with a method matcher 
    399434     */