Tr does not work with non-english chars

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-forum.com/\.

In your second example, the string contains 'a' but after tr....

Harry

···

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-forum.com/\.

--

This is the idea of a genius , sorry couldn't resist folks :wink:
<snip>

Robert

···

On 2/10/07, J. mp <joaomiguel.pereira@gmail.com> wrote:

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

--
We have not succeeded in answering all of our questions.
In fact, in some ways, we are more confused than ever.
But we feel we are confused on a higher level and about more important
things.
-Anonymous

Robert Dober 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 :wink:
<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

···

On 2/10/07, J. mp <joaomiguel.pereira@gmail.com> wrote:

--
Posted via http://www.ruby-forum.com/\.

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

···

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 :wink:
> <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/\.

--

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 :frowning:

I meant you transformed U.S.A into USB, but *both* are very useful!
Cheers
Robert

···

On 2/10/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 :wink:
> <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/\.

--
We have not succeeded in answering all of our questions.
In fact, in some ways, we are more confused than ever.
But we feel we are confused on a higher level and about more important
things.
-Anonymous

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 :wink:

--
Posted via http://www.ruby-forum.com/\.

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-forum.com/\.

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 :frowning:

I meant you transformed U.S.A into USB, but *both* are very useful!
Cheers
Robert

--

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

···

--
Posted via http://www.ruby-forum.com/\.

> 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. :slight_smile:

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

···

--

Well, tell them to stop it. :slight_smile:

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-forum.com/\.