[Bug] Sketchup.write_default on Mac
-
I have a problem with storing UTF-8 string into "default settings" on Mac.
` Sketchup.read_default("MySettings","MyKey")
nil
Sketchup.write_default("MySettings","MyKey","Test")
true
Sketchup.read_default("MySettings","MyKey")
Test
Sketchup.write_default("MySettings","MyKey","Błąd")
true!
Sketchup.read_default("MySettings","MyKey")
nil!!`Is there any encoding that would let me store the UTF8 string into the default settings on Mac?
Where can I locate the ini file SketchUp stores the data?Thanks
Tomasz -
@tomasz said:
Where can I locate the ini file SketchUp stores the data?
Thanks
Tomasz(non developer response below.. proceed with care
)
i think you're looking for the .plist file on mac instead.. in which case, it's at
user/ Library/ Preferences/ com.google.sketchuppro8.plist (or whatever SU version)..
note*-- user library is hidden on new mac OSes..
-
As Jeff says, on a Mac its stored as some XML (with a .plist extension)
Why don't you just escape it:
Save it as Sketchup.write_default("MySettings","MyKey", "Błąd".unpack('H')[0])*
Load it as Sketchup.read_default("MySettings","MyKey").to_a.pack('H')*
Tadaa!
-
@unknownuser said:
i think you're looking for the .plist file on mac instead.. in which case, it's at
user/ Library/ Preferences/ com.google.sketchuppro8.plist (or whatever SU version)Thanks. Have fount it. Everything is written fine there!
It is theread
method that doesn't convert it back to UTF8, I guess.Btw. I have found MainFrame_M2Upgrade Boolean entry
(switched off)
@adamb said:
Why don't you just escape it:
Save it as Sketchup.write_default("MySettings","MyKey", "Błąd".unpack('H')[0])*Load it as Sketchup.read_default("MySettings","MyKey").to_a.pack('H')*
Tadaa!
Thanks. You are right.
I was thinking of reading the file from C++, but it is too much to find the right one. Old Ruby way will work better.I will report the bug.
-
Yea, the attributes seem to be picky about what you can store, without giving much hints to what is accepted - nor tell you when something fails.
To store data, non-text, I've been using Base64. -
Keep in mind that
read_default
passes the attribute text througheval()
before it is returned, apparently with arescue nil
clause (or modifier.)This is why we cannot have any un-escaped embedded double-quote characters in the attribute.
Advertisement