Weird conversion in IRB

For some reason I have this line I am pasting from a text file into IRB,
and it is converting the spaces into the word “bee”

IF test @yst-hide-felicite

irb(main):001:0> WHENbeeNONEMPTYbee@horizontal-featured-item-text

If I paste it into the normal prompt it works though…

C:\rails_apps\transfer-util>WHENÂ NONEMPTYÂ @horizontal-featured-item-text

It works everywhere but IRB. The file I am copying this from I made, so
I know they are just spaces.

Anyone else seen anything like this?

~Jeremy

Jeremy W. wrote:

For some reason I have this line I am pasting from a text file into IRB,
and it is converting the spaces into the word “bee”

IF test @yst-hide-felicite

irb(main):001:0> WHENbeeNONEMPTYbee@horizontal-featured-item-text

If I paste it into the normal prompt it works though…

C:\rails_apps\transfer-util>WHENÂ NONEMPTYÂ @horizontal-featured-item-text

It works everywhere but IRB. The file I am copying this from I made, so
I know they are just spaces.

Anyone else seen anything like this?

~Jeremy

ok, let me re-phrase something. When I made the file, I didn’t write it
by hand. I used another script to generate it. I guess in a text editor,
they look like spaces, but when I do a

puts file.readlines[0]

I get back
=> “WHEN\302\240NONEMPTY\302\240@horizontal-featured-item-text2\n”

what is \302\240

??

ok, I’ve been reading more on it. I guess it’s like unicode or
something…

anyway, I need help with it still. I have a string,

“FOR-EACH-OBJECT\302\240@contents2\n”

and I want to split it by the \302\240, just doing

string.split(’\302\240’) doesn’t work.

Any ideas?

Thanks,
~Jeremy

Jeremy W. wrote:

ok, I’ve been reading more on it. I guess it’s like unicode or
something…

anyway, I need help with it still. I have a string,

“FOR-EACH-OBJECT\302\240@contents2\n”

and I want to split it by the \302\240, just doing

string.split(’\302\240’) doesn’t work.

Any ideas?

Thanks,
~Jeremy

Splitting with a regex works.

string.split(/\302\240/)

hth,

Siep

Jeremy W. wrote:

ok, I’ve been reading more on it. I guess it’s like unicode or
something…

Yep, you can even see the string broken into unicode chars:

irb(main):009:0> src.scan(/./u)
=> [“W”, “H”, “E”, “N”, “\302\240”, “N”, “O”, “N”, “E”, “M”, “P”, “T”,
“Y”, “\302\240”, “@”, “h”, “o”, “r”, “i”, “z”, “o”, “n”, “t”, “a”, “l”,
“-”, “f”, “e”, “a”, “t”, “u”, “r”, “e”, “d”, “-”, “i”, “t”, “e”, “m”,
“-”, “t”, “e”, “x”, “t”, “2”]

and I want to split it by the \302\240, just doing

string.split(’\302\240’) doesn’t work.

You need double-quotes, not single-quotes, for the \nnn syntax to be
turned into single bytes.

irb(main):011:0> src.split("\302\240")
=> [“WHEN”, “NONEMPTY”, “@horizontal-featured-item-text2\n”]

wow, that’s so weird, but it worked! Thanks man.

~Jeremy

Brian C. wrote:

Jeremy W. wrote:

ok, I’ve been reading more on it. I guess it’s like unicode or
something…

Yep, you can even see the string broken into unicode chars:

irb(main):009:0> src.scan(/./u)
=> [“W”, “H”, “E”, “N”, “\302\240”, “N”, “O”, “N”, “E”, “M”, “P”, “T”,
“Y”, “\302\240”, “@”, “h”, “o”, “r”, “i”, “z”, “o”, “n”, “t”, “a”, “l”,
“-”, “f”, “e”, “a”, “t”, “u”, “r”, “e”, “d”, “-”, “i”, “t”, “e”, “m”,
“-”, “t”, “e”, “x”, “t”, “2”]

and I want to split it by the \302\240, just doing

string.split(’\302\240’) doesn’t work.

You need double-quotes, not single-quotes, for the \nnn syntax to be
turned into single bytes.

irb(main):011:0> src.split("\302\240")
=> [“WHEN”, “NONEMPTY”, “@horizontal-featured-item-text2\n”]