Closed lyon-fnal closed 4 years ago
I don't get that error on my computer (Linux, gnuplot v5.2.8), however I think your solution is more appropriate.
Thank you very much for spotting this out and for providing a PR!
Must be a Mac thing. Anyway, thanks for merging the PR so quickly!
I found the problem, it is related to gnuplot character encoding.
Before your PR:
gpvars()[:DEGREE_SIGN]
used to return the uf8 codes ("\\302\\260"
).Your PR fix the first issue, while the second (forcing UTF8 encoding) is now fixed here: https://github.com/gcalderone/Gnuplot.jl/blob/83c59ae682965ad3d7ef54bd9b841806a776363f/src/Gnuplot.jl#L553
When I try an example in the documentation in the Named datasets section, I get a failure in the
gpvars()
call...The last line generates...
I'm running
Gnuplot v1.3.0
I tracked down the problem, which is at this line... https://github.com/gcalderone/Gnuplot.jl/blob/2713f8517ed7361fe921d4da364c5ca724a8a841/src/Gnuplot.jl#L2257
Arithmetic with
end
for a string containing (apparently) multi-byte characters is unsafe. See https://docs.julialang.org/en/v1/manual/strings/#Unicode-and-UTF-8-1 .The way to fix this is to replace that line with,
I think the
2:
is safe because you know the first character in the string is a double quote (a single-byte character).I'm a little surprised that perhaps no one else has seen this. This happens for me for the Gnuplot variable,
I don't think I have anything special in my
gnuplot
setup. I'm running 5.2.8.Can you make this one-line fix or do you want me to make a pull request?
Thanks!! -- Adam