In each of your examples, you execute a shell command. As a first step, I have to make sure that your shell command executes as you expect when you enter it directly:
touch cat cat <
If you get errors in the shell, this is one of two possibilities: the shell command does not understand the character encoding, or the file name needs quotation marks to distinguish it accordingly.
Ruby 1.9 understands character encodings that Ruby 1.8 did not. You will need to do a little research to determine which character your shell environment encodes. Once you do this, you will create the commands as normal lines:
touch = "touch #{s}".force_encoding("UTF-8")
and then run the command:
`#{touch}`
I believe that the default encoding of Ruby 1.9 is UTF-8. Ruby 1.8 has no concept of coding, and a string is just an array of bytes. Unfortunately, not all pieces of software understand unicode or character encoding concepts (like Ruby 1.8). In these cases, the system will use everything that is encoded by default. I suspect your shell environment may be one of these programs.
source share