[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

special characters screwing up string operations

Aryk Grosz

4/21/2009 7:42:00 PM

Im doing some manipulation of strings, and there are some characters
that Ruby just really does not like:

â?? â??

If you try to paste these into a Ruby console the cursor will jump
around. Likewise, if you put it in a string and try to do text[5,4] it
will give you the wrong piece of the text.

How do I get around this. Is there some special escape command or do I
just have to gsub these characters?
--
Posted via http://www.ruby-....

8 Answers

Robert Dober

4/21/2009 8:33:00 PM

0

On Tue, Apr 21, 2009 at 9:41 PM, Aryk Grosz <tennisbum2002@hotmail.com> wro=
te:
> Im doing some manipulation of strings, and there are some characters
> that Ruby just really does not like:
>
> =93 =96
>
> If you try to paste these into a Ruby console the cursor will jump
> around. Likewise, if you put it in a string and try to do text[5,4] it
> will give you the wrong piece of the text.
With the information at hand it might be an encoding issue,
what version are you using, please paste the output of ruby -v
R.

pjb

4/21/2009 8:50:00 PM

0

Aryk Grosz <tennisbum2002@hotmail.com> writes:

> Im doing some manipulation of strings, and there are some characters
> that Ruby just really does not like:
>
> “ –
>
> If you try to paste these into a Ruby console the cursor will jump
> around. Likewise, if you put it in a string and try to do text[5,4] it
> will give you the wrong piece of the text.
>
> How do I get around this. Is there some special escape command or do I
> just have to gsub these characters?

Perhaps you could try a real programming language?

C/USER[1]> (length "abcde\“\ \–fgh")
11
C/USER[2]> (subseq "abcde\“\ \–fgh" 5 6)
"“"
C/USER[3]> (subseq "abcde\“\ \–fgh" 5 9)
"“ –f"
C/USER[4]> (map 'list (function char-code) "abcde“ –fgh")
(97 98 99 100 101 8220 32 8211 102 103 104)

--
__Pascal Bourguignon__

Robert Dober

4/21/2009 9:40:00 PM

0

On Tue, Apr 21, 2009 at 10:55 PM, Pascal J. Bourguignon
<pjb@informatimago.com> wrote:

> Perhaps you could try a real programming language?
Adam do not pay attention, Pascal is convinced that CL is a real
programming language. (1)
Never mind, he is a nice guy, just suffering from parenoia. ;)
R.

(1) He is not the only one.
--=20
Si tu veux construire un bateau ...
Ne rassemble pas des hommes pour aller chercher du bois, pr=E9parer des
outils, r=E9partir les t=E2ches, all=E9ger le travail=85 mais enseigne aux
gens la nostalgie de l=92infini de la mer.

If you want to build a ship, don=92t herd people together to collect
wood and don=92t assign them tasks and work, but rather teach them to
long for the endless immensity of the sea.

--
Antoine de Saint-Exup=E9ry

Eric Hodel

4/21/2009 10:14:00 PM

0

On Apr 21, 2009, at 12:41, Aryk Grosz wrote:

> Im doing some manipulation of strings, and there are some characters
> that Ruby just really does not like:
>
> =93 =96
>
> If you try to paste these into a Ruby console the cursor will jump
> around. Likewise, if you put it in a string and try to do text[5,4] it
> will give you the wrong piece of the text.
>
> How do I get around this. Is there some special escape command or do I
> just have to gsub these characters?

My console doesn't allow me to paste these characters into irb (OS X, =20=

it beeps when I try) so I think it is Readline's fault.

I can read them with gets:

$ ruby -e 'p gets'
=93 =96
"\342\200\234 \342\200\223\n"

You'll probably need to adjust your terminal settings to accept these =20=

characters.=

cuppajoe2go

10/15/2011 7:13:00 AM

0

On Oct 14, 3:57 pm, "who?" <yourimageunre...@sbcglobal.net> wrote:
> On Oct 14, 5:34 pm, Buddyb...@webtv.net wrote:
>
> > neither.
> > the yoke outshined them both.
>
> Both cause they wouldn't have been the same tight
> group without them. Most musicians wouldn't have
> put up with getting one song per LP for the length
> of time Harrison did.

I'm not sure the question is complete enough. Important to what?
Success? Longevity? If pressed for a definitive answer I'll go with
Starr. Paul and John kept each other in check, so to speak, while
George was fastly progressing musically - and spiritually. Harrison
might've wanted out long before the actual end, whereas Starrr was was
not exactly emerging in the same way. Ringo never demanded more
presence musically and remained the rock steady salt of the earth in
the band. George introduced and contributed SO MUCH to the band
though. May not be an answerable question...you're on your own :-/

BlackMonk

10/16/2011 1:48:00 AM

0

On 10/14/2011 6:57 PM, who? wrote:
> On Oct 14, 5:34 pm, Buddyb...@webtv.net wrote:
>> neither.
>> the yoke outshined them both.
>
> Both cause they wouldn't have been the same tight
> group without them. Most musicians wouldn't have
> put up with getting one song per LP for the length
> of time Harrison did.

Two songs per LP. He wasn't really a writer until 65 and he got an
average of one song per LP side from Help on.

That would make each LP side average out to three John songs, three Paul
songs and one George song. That sounds about right, since John and Paul
were the songwriters of the group.

It might have been interesting if they established a rule that, since
George is taking away John and Paul's job on the song, they get to take
away his, so all Harrison originals would have to have either Lennon or
McCartney on lead guitar.


Jeff

10/16/2011 5:27:00 AM

0

On Oct 15, 8:48 pm, BlackMonk <BlackM...@msn.com> wrote:
> On 10/14/2011 6:57 PM, who? wrote:
>
> > On Oct 14, 5:34 pm, Buddyb...@webtv.net wrote:
> >> neither.
> >> the yoke outshined them both.
>
> > Both cause they wouldn't have been the same tight
> > group without them. Most musicians wouldn't have
> > put up with getting one song per LP for the length
> > of time Harrison did.
>
> Two songs per LP. He wasn't really a writer until 65 and he got an
> average of one song per LP side from Help on.

You're right. I haven't listened to the Beatles for a while.

> That would make each LP side average out to three John songs, three Paul
> songs and one George song. That sounds about right, since John and Paul
> were the songwriters of the group.

I think George just got restless knowing that the Beatles bubble was
going to burst one day, and what would he be singing the rest of
his life? I think he should have covered "I'm happy just to dance
with you" live as a solo artist.

> It might have been interesting if they established a rule that, since
> George is taking away John and Paul's job on the song, they get to take
> away his, so all Harrison originals would have to have either Lennon or
> McCartney on lead guitar.

I don't think George would have cared as long as they were his songs,
cause he didn't play much lead as a solo artist.

Rock FZYGC

10/17/2011 6:23:00 PM

0

On Oct 15, 2:12 am, cuppajoe2go <hoss5...@yahoo.com> wrote:
> On Oct 14, 3:57 pm, "who?" <yourimageunre...@sbcglobal.net> wrote:
>
> > On Oct 14, 5:34 pm, Buddyb...@webtv.net wrote:
>
> > > neither.
> > > the yoke outshined them both.
>
> > Both cause they wouldn't have been the same tight
> > group without them. Most musicians wouldn't have
> > put up with getting one song per LP for the length
> > of time Harrison did.
>
> I'm not sure the question is complete enough. Important to what?
> Success? Longevity?

In terms of contributions to the Beatles sound?


>If pressed for a definitive answer I'll go with
> Starr.  Paul and John kept each other in check, so to speak, while
> George was fastly progressing musically - and spiritually. Harrison
> might've wanted out long before the actual end, whereas Starrr was was
> not exactly emerging in the same way. Ringo never demanded more
> presence musically and remained the rock steady salt of the earth in
> the band. George introduced and contributed SO MUCH to the band
> though. May not be an answerable question...you're on your own :-/