Using the Registry - Any Gotchas?
-
Is there anything to watch for when using the
Sketchup.write_defaultandSketchup.read_defaultmethods?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 7because 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.
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_defaultandSketchup.read_defaultmethods?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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement