Weird conversion in IRB

J

Jeremy Woertink

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
 
J

Jeremy Woertink

Jeremy said:
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

??
 
J

Jeremy Woertink

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
 
S

Siep Korteling

Jeremy said:
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
 
B

Brian Candler

Jeremy said:
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"]
 
J

Jeremy Woertink

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

~Jeremy

Brian said:
Jeremy said:
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"]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top