PyGraphviz tries to encode string data into UTF-8 since that is what
Graphviz handles. So e.g. the following will work:
In [27]: import pygraphviz
In [28]: G=pygraphviz.AGraph()
In [29]: n=u"\u2713"
In [30]: G.add_node(n)
In [31]: G.nodes()
Out[31]: ['\xe2\x9c\x93']
In [32]: G.write()
strict graph {
✓;
}
If you find some places (attributes?) where this isn't handled
correctly please let us know.
Aric
Well, we had previously fixed one of those at least (raising the exception).
There are a few other places (in addition to the one you found)
where we are not encoding to UTF-8 before we attempt to store
data into the Graphviz data structure. I'll see if I can figure out a clean
way to handle that.
Aric
Do you understand the Graphviz text encoding enough to give advice
on how to implement this? I get confused every time I look at
http://www.graphviz.org/doc/FAQ.html#Q10
and
http://www.graphviz.org/doc/info/lang.html
Normally I would probably want to store string-like data as unicode
and then encode to whatever the user specifies on output. But we are
storing string data in the internal Graphviz data structures
(c.f. libcgraph) and need to encode to whatever that requires.
Aric