jamesscottbrown / pyyed

A simple Python library to export networks to yEd
BSD 3-Clause "New" or "Revised" License
82 stars 38 forks source link

Invalid Byte 1 of 1-Byte UTF-8 Sequence on Opening .graphml File #22

Closed LarsaSolidor closed 4 years ago

LarsaSolidor commented 5 years ago

I export a .graphml file using

filename = 'A File Name'
with(open(f{filename}.graphml, 'w') as fp:
    fp.write(g.get_graph())

The resulting .graphml file gives me the following error when opened in yEd:

y.H.B.B.a: SAX error: Invalid byte 1 of 1-byte UTF-8 sequence.
    at com.yworks.A.B.G.A.U$H.ā(Unknown Source)
    at com.yworks.A.B.G.A.U.ā(Unknown Source)
    at com.yworks.A.B.G.A.Q.ā(Unknown Source)
    at y.H.G.ā(Unknown Source)
    at y.B.A.M.Đ(Unknown Source)
    at y.B.d.č(Unknown Source)
    at y.B.d.ā(Unknown Source)
    at y.B.d.ă(Unknown Source)
    at com.yworks.A.B.W.ă(Unknown Source)
    at com.yworks.A.B.W.ā(Unknown Source)
    at com.yworks.A.J.P.ā(Unknown Source)
    at com.yworks.A.J.P.ā(Unknown Source)
    at com.yworks.A.J.G.ā(Unknown Source)
    at com.yworks.A.J.G.ą(Unknown Source)
    at com.yworks.A.yEd$3.run(Unknown Source)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 12; Invalid byte 1 of 1-byte UTF-8 sequence.
    at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:262)
    at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
    at com.yworks.A.B.G.A.H.ā(Unknown Source)
    at com.yworks.A.B.G.A.H.ā(Unknown Source)
    ... 28 more
Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
    at java.xml/com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:702)
    at java.xml/com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:568)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1904)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.peekChar(XMLEntityScanner.java:508)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2647)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:534)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:246)
    ... 31 more
jamesscottbrown commented 5 years ago

Does your network include any non-ascii characters (e.g., accented characters, ligatures like æ, emojis, or characters from other alphabets)?

LarsaSolidor commented 5 years ago

Hi, I don't think so. The characters in the filepath are:

-.:ACDILOPSTU\_abcdehiklmnoprstuv

With ASCII codes:

[32, 45, 46, 58, 65, 67, 68, 73, 76, 79, 80, 83, 84, 85, 92, 95, 97, 98, 99, 100, 101, 104, 105, 107, 108, 109, 110, 111, 112, 114, 115, 116, 117, 118]