Strange behaviour of console with non English symbols

Hi everyone, sorry for bad English.
Can anybody ask why there is an error?

require ‘shellwords’

a = [‘ok_привет’, ‘fail_мистика’]

a.each do |s|
touch #{s}
cat #{s}
tr -d '\r' < #{s}
tr -d '\r' < #{s.shellescape}
end

sh: cannot open fail_ми�тика: No such file
sh: cannot open fail_ми�тика: No such file

s = “мистика”

touch #{s}
cat #{s}
cat < #{s}

Result fails. WTF. Why?

FWIW this works for me (I needed to specify encoding):

encoding: ISO8859-5

s = “”

touch #{s}
cat #{s}
cat < #{s}

This is with Ruby 1.9.2p80. Are you still getting a “No such file”
error? Could it be a permission issue?

no, permissions are ok

woto@woto-work:/tmp$ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]

woto@woto-work:/tmp$ uname -a
Linux woto-work 2.6.32-26-generic #48-Ubuntu SMP Wed Nov 24 10:14:11
UTC 2010 x86_64 GNU/Linux

woto@woto-work:/tmp$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1 LTS
Release: 10.04
Codename: lucid

I’ve added on top

encoding: ISO8859-5

or

encoding: UTF-8

still getting error

More over for example this works good

s = “работает”

touch #{s}
cat #{s}
cat < #{s}

Problem is only when Russian symbol ‘с’ in the word

As i told. The problem arise when the command contains ‘<’ and Russian
symbol ‘с’

On 28 December 2010 12:09, woto [email protected] wrote:

tr -d '\r' < #{s}
tr -d '\r' < #{s.shellescape}
end

sh: cannot open fail_ми�тика: No such file
sh: cannot open fail_ми�тика: No such file

Which commands are failing? Have you checked the others are working
as expected. It would be better to reduce the problem to the simplest
that fails. Do you need to have the array of strings for example?

I suggest you reduce the example to the simplest code that fails and
re-post that.

Colin

I tried the same example I posted above with 1.8.7 (2009-06-12
patchlevel 174) and it works there too, without the encoding specified
(that all changed between 1.8 and 1.9 AFAIK).

The post title mentioned the console. Are you running from the command
line, IRB, Rails console…?

I have a difficulties with an explanation of problem. I asked this
question also on stackoverflow. May be English speaking developers
will help me with explanation. Because one developer also confirmed
this problem.