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?

On 2/11/07, J. mp [email protected] wrote:

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/10/07, J. mp [email protected] 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:

Robert

On 2/11/07, J. mp [email protected] 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’)

Harry wrote:

On 2/11/07, J. mp [email protected] 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 ã

Robert D. wrote:

On 2/10/07, J. mp [email protected] 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:

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

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
ã

On 2/10/07, J. mp [email protected] wrote:

This is the idea of a genius , sorry couldn’t resist folks :wink:

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

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

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