# String Question... Real n00b here

**URL:** <https://www.ruby-forum.com/t/string-question-real-n00b-here/164904>\
**Category:** Ruby\
**Created:** [April 7, 2009, 8:55am UTC](https://www.ruby-forum.com/t/string-question-real-n00b-here/164904 "2009-04-07T08:55:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [April 7, 2009, 8:55am UTC](https://www.ruby-forum.com/t/string-question-real-n00b-here/164904/1 "2009-04-07T08:55:49Z")

</div>

I just picked up Ruby today after a friend mentioned Watir to me…

So in my meager hours with the language, I have found something that has  
me completely STUMPED.

I am trying to concat 3 strings together to form a URL. The URL happens  
to have some base64 in the middle of it. So I am using a method to  
encode the string I want in the URL and trying to concat the string back  
together. However, it seems to be displaying on two lines rather than  
one.

require “base64”  
dec = 3251706  
myURL = “[http://warbook.workisboring.com/diplomacy/userPage?target=](http://warbook.workisboring.com/diplomacy/userPage?target=)” +  
Base64.encode64(dec.to\_s()) + “&secure=1&search=1;”  
puts myURL

The output is this:  
[http://warbook.workisboring.com/diplomacy/userPage?target=MzI1MTcwNg==](http://warbook.workisboring.com/diplomacy/userPage?target=MzI1MTcwNg==)  
&secure=1&search=1;

where as I need it to be all on one line to work…

---

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [April 7, 2009, 9:06am UTC](https://www.ruby-forum.com/t/string-question-real-n00b-here/164904/2 "2009-04-07T09:06:54Z")

</div>

Chris Mays wrote:

> where as I need it to be all on one line to work…

Try putting .chomp after the encode64() call:

irb(main):004:0\> Base64.encode64(“foo”)  
=\> “Zm9v\n”  
irb(main):005:0\> Base64.encode64(“foo”).chomp  
=\> “Zm9v”

No idea why encode64 puts the extra newline there… maybe someone else  
can explain.

---

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [April 7, 2009, 9:09am UTC](https://www.ruby-forum.com/t/string-question-real-n00b-here/164904/3 "2009-04-07T09:09:36Z")

</div>

Joel VanderWerf wrote:

> Try putting .chomp after the encode64() call:

_exasperated sigh_ such a simple explanation.

Thanks
