Ruby question, max length of strings

Am I correct in assuming that the max length of a string is 65,535 on a
32 bit
platform? Anyway around this, other classes, 64 bit platform?

TIA,
Jeffrey

Jeffrey L. Taylor wrote:

Am I correct in assuming that the max length of a string is 65,535 on a
32 bit
platform? Anyway around this, other classes, 64 bit platform?

TIA,
Jeffrey

What would make you assume this? Simplest demonstration:

irb(main):004:0> s = “a”*70000;nil
=> nil
irb(main):005:0> s.size
=> 70000
irb(main):006:0>

Also, keep in mind Ruby has no separate representation for raw 8bit
data. Only Strings. How would it be able to store a 65KB+ file in
memory?

The only limit to Ruby string is is available memory.

Paul H. wrote:

Jeffrey L. Taylor wrote:

Am I correct in assuming that the max length of a string is 65,535 on a
32 bit
platform? Anyway around this, other classes, 64 bit platform?

TIA,
Jeffrey

What would make you assume this? Simplest demonstration:

irb(main):004:0> s = “a”*70000;nil
=> nil
irb(main):005:0> s.size
=> 70000
irb(main):006:0>

Also, keep in mind Ruby has no separate representation for raw 8bit
data. Only Strings. How would it be able to store a 65KB+ file in
memory?

The only limit to Ruby string is is available memory.

btw that irb session was
irb(main):001:0> RUBY_VERSION
=> “1.9.1”
irb(main):002:0> RUBY_PLATFORM
=> “i386-mingw32”

Quoting Paul H. [email protected]:

The only limit to Ruby string is is available memory.

btw that irb session was
irb(main):001:0> RUBY_VERSION
=> “1.9.1”
irb(main):002:0> RUBY_PLATFORM
=> “i386-mingw32”

I find the same results. Checking further, I find that it’s MySQL TEXT
column
that is limited to 65,535 bytes.

Thank you,
Jeffrey

irb(main):001:0> s = “a”*70000;nil
=> nil
irb(main):002:0> s.size
=> 70000
irb(main):003:0> RUBY_VERSION
=> “1.8.7”
irb(main):004:0> RUBY_PLATFORM
=> “i586-linux”
irb(main):005:0>

On Aug 19, 3:14 am, “Jeffrey L. Taylor” [email protected] wrote:

platform? Anyway around this, other classes, 64 bit platform?
irb(main):006:0>
irb(main):002:0> RUBY_PLATFORM
=> “i386-mingw32”

I find the same results. Checking further, I find that it’s MySQL TEXT column
that is limited to 65,535 bytes.

Indeed. However, if you specify a :limit value higher than 65535 in
the migration that creates the text column Rails will promote it to a
‘mediumtext’, which has a limit of (I think) 16M. Pushing the limit
past that will again promote the column to ‘longtext’, which has a
limit >2G.

–Matt J.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs