[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

tr does not work with non-english chars

J. mp

2/10/2007 8:33:00 PM

Hi,
if I do this
?> puts "usa".tr('a','b')
usb
=> nil

it works

but with this:
>> puts "usa".tr('ã','b')

It stays forever waiting for not sure about what. Does not work

what I'm doing wrong?

--
Posted via http://www.ruby-....

7 Answers

Harry

2/10/2007 8:45:00 PM

0

On 2/11/07, J. mp <joaomiguel.pereira@gmail.com> wrote:
> Hi,
> if I do this
> ?> puts "usa".tr('a','b')
> usb
> => nil
>
> it works
>
> but with this:
> >> puts "usa".tr('ã','b')
>
> It stays forever waiting for not sure about what. Does not work
>
> what I'm doing wrong?
>
> --
> Posted via http://www.ruby-....
>
>
In your second example, the string contains 'a' but after tr....

Harry

--
http://www.kakueki.com/ruby...

J. mp

2/10/2007 9:23:00 PM

0

Robert Dober wrote:
> On 2/10/07, J. mp <joaomiguel.pereira@gmail.com> wrote:
>>
>> Hi,
>> if I do this
>> ?> puts "usa".tr('a','b')
>> usb
>> => nil
>
>
> This is the idea of a genius , sorry couldn't resist folks ;)
> <snip>
>
> Robert

I can't get my answer from your answers, sorry
anyway, the case is:
>> puts "usã".tr('ã','b') -> don't work

the result shoul be usb but it blocks



--
Posted via http://www.ruby-....

Harry

2/10/2007 9:35:00 PM

0

On 2/11/07, J. mp <joaomiguel.pereira@gmail.com> wrote:> Robert Dober wrote:> > On 2/10/07, J. mp <joaomiguel.pereira@gmail.com> wrote:> >>> >> Hi,> >> if I do this> >> ?> puts "usa".tr('a','b')> >> usb> >> => nil> >> >> > This is the idea of a genius , sorry couldn't resist folks ;)> > <snip>> >> > Robert>> I can't get my answer from your answers, sorry> anyway, the case is:> >> puts "usã".tr('ã','b') -> don't work>> the result shoul be usb but it blocks>>>> --> Posted via http://www.ruby-forum.com/.&g... "us?".sub('?','a')-- http://www.kakueki.com/ruby...

J. mp

2/10/2007 9:39:00 PM

0

Harry wrote:
> On 2/11/07, J. mp <joaomiguel.pereira@gmail.com> wrote:
>> > This is the idea of a genius , sorry couldn't resist folks ;)
>>
>>
>> --
>> Posted via http://www.ruby-....
>>
>>
> puts "uså¼·".sub('å¼·','a')

cool but what I want is

puts "usã".sub('ã','a') not puts "us強".sub('強','a')

the users are using the char ã

--
Posted via http://www.ruby-....

J. mp

2/10/2007 9:58:00 PM

0


>
> Sorry that I wasted your time!
> It was just a stupid joke, really stupid, I put a smiley and appologies
> but
> that was not good enough :(
>
> I meant you transformed U.S.A into USB, but *both* are very useful!
> Cheers
> Robert
>
> --

that's ok :) it seem you're not seeing my problem I'm using the char
&atilde;

--
Posted via http://www.ruby-....

Harry

2/10/2007 10:20:00 PM

0

> > puts "us?".sub('?','a')>> cool but what I want is>> puts "usã".sub('ã','a') not puts "us?".sub('?','a')>> the users are using the char ã>>Well, tell them to stop it. :)Seriously, I only work with English and Japanese characters so if thatdidn't fix your problem then the only thing I know to try is $KCODE ='u'.If that doesn't help, maybe someone else can help.Harry-- http://www.kakueki.com/ruby...

J. mp

2/10/2007 11:39:00 PM

0


>>
> Well, tell them to stop it. :)
>
> Seriously, I only work with English and Japanese characters so if that
> didn't fix your problem then the only thing I know to try is $KCODE =
> 'u'.
> If that doesn't help, maybe someone else can help.
>
> Harry

Thanks all, i'm done

--
Posted via http://www.ruby-....