Open vizvamitra opened 8 years ago
Same issue here but with swedish characters. Any progress? As far as I can tell GraphViz supports unicode so I guess it is called in the wrong way somehow.
@froderik I ended up writing my own simple implementation of a tool that converts directed graph to dot string and feeding this string directly to dot command.
aah - thanks for posting! We have a dot file already that is generated from another source so maybe we should try to just pass it directly to dot
instead of using graphviz. What do you think?
@froderik it does work with russian so I think it'll do so with swedish too =)
system('dot /path/to/dot/file.dot -Tsvg -o /path/to/output/file.svg')
But you will probably need to handle all posible errors from dot command (I believe in this gem they handle errors here with just raising "Error from #{cmd}:\n#{errors}"
)
Also Ruby-Graphviz gem is quite heavy and I guess it'll be beter not to use it if your use cases are as simple as just format simple graph to dot or convert dot to image
great! will try it right away!
@vizvamitra - works like a charm - thanks for the help!
Any update about this?
I got a similar issue with Chinese
character in the label of nodes.
script as the following
require "graphviz"
g = GraphViz::new( "G" )
g.add_nodes "chinese", label: '你好'
g.output( :dot => "x.dot" )
would generate dot
as this:
digraph G {
graph [bb="0,0,115.69,36"];
node [label="\N"];
chinese [height=0.5,
label="\u4F60\u597D",
pos="57.845,18",
width=1.6068];
}
and will generate graph
contains node with label as u4F60u597D
, any solutions or walk around please ?
It's platform-related issue.
to_gv
uses 'string'.to_s.inspect.gsub( "\\\\", "\\" )
to escape string, and inspect
behaves differently on Windows.
c:\script>ruby test.rb
"\u4F60\u597D"
[user@i2 ~]$ ruby test.rb
"你好"
The problem is in lib/graphviz/utils.rb:46 function output_and_errors_from_command: Open3 works in binmode, that force Encoding:ASCII-8BIT
this worked for me: <
for the less than sign.
This issue is still present in 2021 when labels have UTF-8 character codes, in our case French names with é character.
The problem is in lib/graphviz/utils.rb:46 function output_and_errors_from_command: Open3 works in binmode, that force Encoding:ASCII-8BIT
When producing a SVG using -Tsvg, binode should be false
. Working on a PR with hopes to finally resolve this. Is this gem actively maintained?
PR submitted - not sure if anyone is listening though.
To contributors: Thank you for your consideration on my PR and for supporting this great gem.
I've found some strange behavior:
(ruby 2.0.0p353, ruby-graphviz 1.2.2, graphviz 2.36.0)