#41484 [Opn->Bgs]: DOMDocument doesn`t convert character-set automaticly

From: Date: Thu, 24 May 2007 09:25:19 +0000
Subject: #41484 [Opn->Bgs]: DOMDocument doesn`t convert character-set automaticly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112988@lists.php.net to get a copy of this message
ID: 41484 Updated by: chregu@php.net Reported By: songqi at baidu dot com -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: Redhat linux PHP Version: 5.2.2 New Comment: $doc->createElement("") and all other DOM methods (except the ->load..() methods) always expects UTF-8 encoded strings That's how it works. Not a bug. Previous Comments: ------------------------------------------------------------------------ [2007-05-24 08:54:55] songqi at baidu dot com Description: ------------ I want to use DOM Functions to generate xml with some gb2312 characters, but DOMDocument doesn`t convert character-set to utf-8 automaticly, and throws a exception 'DOMException' with message 'Invalid Character Error'. Reproduce code: --------------- $doc = new DOMDocument("1.0","gb2312"); $doc->createElement("¹Ø¼ü×Ö"); echo $doc->saveXML(); Expected result: ---------------- <?xml version="1.0" encoding="gb2312"?> <¹Ø¼ü×Ö/> Actual result: -------------- Fatal error: Uncaught exception 'DOMException' with message 'Invalid Character Error' in /home/songq/local/htdocs/test/Auth.php:7 Stack trace: #0 /home/songq/local/htdocs/test/Auth.php(7): DOMDocument->createElement('??????') #1 {main} thrown in /home/songq/local/htdocs/test/Auth.php on line 7 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41484&edit=1

« previous php.bugs (#112988) next »