unicode error in some figure paths
Brad-Hesson opened this issue · comments
When I use an absolute path in windows, the path starts with C:\Users\...
. When the generated python script tries to use that path, it gives the following error:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
This is because the script is interpreting the \U
as a unicode character.
To fix this, generate a raw string in the generated script by putting an 'r' in front of the path string, after fn=
. Change plot.rs line 628 from
let commands = format!("{}\nfn='{}'\n{}", self.buffer, fig_path.to_string_lossy(), txt);
to
let commands = format!("{}\nfn=r'{}'\n{}", self.buffer, fig_path.to_string_lossy(), txt);
Hi there, thanks for the suggestion! It has been fixed (hopefully): #28 Cheers.
By the way, you may use the 0.3.5 version now in Cargo.toml (it has the suggested fix)
Version 0.3.5 works now! Thanks!