Forum: Ruby Longer user input?

84791ec624e0a6086b696c020f0a5927?d=identicon&s=25 Zeil Era (zeilera)
on 2013-06-03 22:54
I think the maximum number of characters in user input ('gets') is 254.
The input that I need to have is a piece of BBCode and it is longer
than 254 characters. So my question is: is there any way to get longer
user input, and if not, is there a way to get around this?

Thanks in advance!
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2013-06-03 23:11
(Received via mailing list)
On Mon, Jun 3, 2013 at 1:54 PM, Zeil Era <lists@ruby-forum.com> wrote:
> I think the maximum number of characters in user input ('gets') is 254.

Why?  And regardless, how hard would it be to test that assumption?
84791ec624e0a6086b696c020f0a5927?d=identicon&s=25 Zeil Era (zeilera)
on 2013-06-03 23:37
Hassan Schroeder wrote in post #1111209:
> On Mon, Jun 3, 2013 at 1:54 PM, Zeil Era <lists@ruby-forum.com> wrote:
>> I think the maximum number of characters in user input ('gets') is 254.
>
> Why?  And regardless, how hard would it be to test that assumption?

It's not an assumption, I have tested it. After typing 254 (or so)
characters, you can't type anymore. Simple as that.
99804651e19d8b0dffbc0da53e39114e?d=identicon&s=25 Adam Prescott (Guest)
on 2013-06-03 23:50
(Received via mailing list)
On 3 June 2013 22:37, Zeil Era <lists@ruby-forum.com> wrote:
> It's not an assumption, I have tested it. After typing 254 (or so)
> characters, you can't type anymore. Simple as that.

You might be reaching a limitation with the terminal you're using.
Ruby doesn't care:

$ echo {1..1000} | wc -c
3893
$ echo {1..1000} | ruby -e 'puts STDIN.gets' | wc -c
3893
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2013-06-04 00:23
(Received via mailing list)
On Mon, Jun 3, 2013 at 2:37 PM, Zeil Era <lists@ruby-forum.com> wrote:

> It's not an assumption, I have tested it. After typing 254 (or so)
> characters, you can't type anymore. Simple as that.

As Adam already pointed out - no. It's apparently a limitation of your
terminal, not `gets`.
D6b6c002a2e97d74c6d03df02dfa20eb?d=identicon&s=25 Per-erik Martin (pem)
on 2013-06-04 09:40
Is this by any chance on Windows? I think it was mentioned in another
recent thread that gets from a terminal has this limitation there.
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 Tamara Temple (Guest)
on 2013-06-05 03:01
(Received via mailing list)
Zeil Era <lists@ruby-forum.com> wrote:
> I think the maximum number of characters in user input ('gets') is 254.
> The input that I need to have is a piece of BBCode and it is longer
> than 254 characters. So my question is: is there any way to get longer
> user input, and if not, is there a way to get around this?

Seriously.

longstring = "x"*10_000
puts "length of longstring: #{longstring.size}"

File.open('/tmp/longfile.txt','w') do |f|
  f.puts longstring
end

File.open('/tmp/longfile.txt','r') do |f|
  longstringin = f.gets.chomp
  raise "strings are not the same!" unless longstring == longstringin
end

puts "same"


Output
======

length of longstring: 10000
same
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 Tamara Temple (Guest)
on 2013-06-05 03:11
(Received via mailing list)
Zeil Era <lists@ruby-forum.com> wrote:

> Posted via http://www.ruby-forum.com/.
>



tamara@caesar:~/Projects/railsapps:2013-06-04@08:08:19
$ ruby -e 'f = gets.chomp; puts "f = #{f}\nf.size = #{f.size}"'
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
f.size = 1671
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.