Using the Registry - Any Gotchas?
-
Is there anything to watch for when using the
Sketchup.write_default
andSketchup.read_default
methods?I know it is a pain if you are trying to store Windows paths in the registry, i.e.
C;\Program Files\Google\Google Sketchup 7
because the '' character is special in strings.
Is it a smart strategy to just encode (am i thinking of escape?) everything before it goes in? (and how might I do that?)
-
There might be something in this thread, starting with the post I've linked to. Todd tried to explain it to me, but I don't know what hex encoding is.
http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=16862&p=134075&hilit=+registry#p134075
Maybe a start?
-
Could do a test with a set of characters and see if it's stored properly. Maybe the method encodes it before saving...
-
@jim said:
Is there anything to watch for when using the
Sketchup.write_default
andSketchup.read_default
methods?I know it is a pain if you are trying to store Windows paths in the registry, i.e.
> C;\Program Files\Google\Google Sketchup 7 >
because the '' character is special in strings.
Is it a smart strategy to just encode (am i thinking of escape?) everything before it goes in? (and how might I do that?)
Yes, but Ruby 'knows' about unix forward slashes so I tend to always do a:
a_filepath_string.gsub(/(\)/, '/')
to everything regardless of platform which then works for PC & Mac.
Adam
-
Thanks Adam, I was actually using the following:
str.gsub!(/\\/, '\\\\')
But I think simply changing it to '/' is a better solution, and will modify inputbox.rb I suppose it's possible for someone to want to use \ for some other string, though.
I'm also escaping double-quotes:
str.gsub!(/"/, '\"')
Thanks.
Advertisement