php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41484 DOMDocument doesn`t convert character-set automaticly
Submitted: 2007-05-24 08:54 UTC Modified: 2007-05-24 09:25 UTC
From: songqi at baidu dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.2.2 OS: Redhat linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: songqi at baidu dot com
New email:
PHP Version: OS:

 

 [2007-05-24 08:54 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-24 09:25 UTC] chregu@php.net
$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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 17:01:29 2024 UTC