This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年03月12日 11:03 by mark, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg63471 - (view) | Author: Mark Summerfield (mark) * | Date: 2008年03月12日 11:03 | |
Here is how to reproduce the bug: from xml.etree.ElementTree import parse import io xml1 = """<?xml version="1.0" encoding="utf8"?> <test>text</test>""" xml2 = """<?xml version="1.0" encoding="utf-8"?> <test>text</test>""" f1 = io.StringIO(xml1) f2 = io.StringIO(xml2) tree2 = parse(f2) # this uses "utf-8" and works fine tree1 = parse(f1) Traceback (most recent call last): File "<pyshell#20>", line 1, in <module> tree1 = parse(f1) File "/home/mark/opt/python30a3/lib/python3.0/xml/etree/ElementTree.py", line 823, in parse tree.parse(source, parser) File "/home/mark/opt/python30a3/lib/python3.0/xml/etree/ElementTree.py", line 561, in parse parser.feed(data) File "/home/mark/opt/python30a3/lib/python3.0/xml/etree/ElementTree.py", line 1201, in feed self._parser.Parse(data, 0) xml.parsers.expat.ExpatError: unknown encoding: line 1, column 30 |
|||
| msg63516 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年03月13日 21:08 | |
Should the parser recognize "utf8"? I looked at the XML standard [1] and it referred me to the IANA's charts [2]. It appears the the only correct way to denote UTF-8 is "UTF-8". [1] http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl [2] http://www.iana.org/assignments/character-sets |
|||
| msg63558 - (view) | Author: Mark Summerfield (mark) * | Date: 2008年03月15日 17:52 | |
You're right that the parser should not recognise "utf8" since it isn't correct XML (as per the references you gave). I made the mistake because I used the etree module and wrote an XML file with encoding "utf8" which etree accepted. I've now switched to using "UTF-8". |
|||
| msg63621 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年03月17日 07:42 | |
Okay to close this, then? |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:31 | admin | set | github: 46531 |
| 2008年03月17日 07:42:41 | georg.brandl | set | status: open -> closed resolution: wont fix messages: + msg63621 nosy: + georg.brandl |
| 2008年03月15日 17:52:04 | mark | set | messages: + msg63558 |
| 2008年03月13日 21:08:32 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages: + msg63516 |
| 2008年03月13日 08:16:17 | mark | set | type: behavior components: + Library (Lib), XML |
| 2008年03月12日 11:03:55 | mark | create | |