Beginner question conversion array <-> string

hello all,

I am trying to convert a string (s="-----boundary with some http
stuff") to an arry to pass it to http::post as data. I need every
character in as an extra element (like aX = ["-","-","b","o"....]

I played with unpack(which looks like a good way) but no success.

My last try was this loop but the characters are safed as figures and
not as characters any more.

s.each_byte do |x|
  aX << x
end

Thanks a lot!
best
Christian

Christian Knoblauch wrote:

hello all,

I am trying to convert a string (s="-----boundary with some http
stuff") to an arry to pass it to http::post as data. I need every
character in as an extra element (like aX = ["-","-","b","o"....]

I played with unpack(which looks like a good way) but no success.

My last try was this loop but the characters are safed as figures and
not as characters any more.

s.each_byte do |x|
  aX << x
end

s.each_byte do |x|
   aX << x.chr
end

Christian Knoblauch wrote:

hello all,

I am trying to convert a string (s="-----boundary with some http
stuff") to an arry to pass it to http::post as data. I need every
character in as an extra element (like aX = ["-","-","b","o"....]

I played with unpack(which looks like a good way) but no success.

My last try was this loop but the characters are safed as figures and
not as characters any more.

s.each_byte do |x|
  aX << x
end

try

  s.split( // )

the easy way is #split

···

On 2005 Jan, 11, at 14:16, Christian Knoblauch wrote:

hello all,

I am trying to convert a string (s="-----boundary with some http
stuff") to an arry to pass it to http::post as data. I need every
character in as an extra element (like aX = ["-","-","b","o"....]

---------
"abc".split('') # => [ "a", "b", "c" ]
---------

Can't you just write the string to the HTTP thingy, though?

//Curne

I played with unpack(which looks like a good way) but no success.

My last try was this loop but the characters are safed as figures and
not as characters any more.

s.each_byte do |x|
  aX << x
end

Thanks a lot!
best
Christian