Embedded Quotes in Ruby Strings
-
Don't read this. It's here for Google search to rescue someone.
In the other languages I've used, from C through JavaScript, quotes were just characters within strings. The only issue was embedding them in string constants where you had to escape them.
Not so in Ruby. It just wreaked havoc with a string-encoded bitmap I was passing from JavaScript. Changing the encoding base from 32 to 48 (48.chr == bits 000000) omits the quotes and solves the problem.
Unencrypted source code for the bitmap-related classes is in the VisMap Ruby.
-
One problem with encoding a binary string into 32 bit integers is that Ruby does not allow 32-bit integers. (It turns anything with more than 31 bits into a 64-bit bignum) And SketchUp doesn't seem to process BIGNUM at all. We wound up using base64 encoding .
-
@al hart said:
We wound up using base64 encoding.
Great minds... Ruby had issues until I switched from chars 32-95 to 48-111.
Advertisement