Encoding issues

I am playing more with encodings and having some problems.

I pasted the text below from web pages… when I view the source in
a browser as UTF-8, it appears correct.

But running it gives an error.

I’m sure I’m doing something dumb here, but I can’t see it.

Note that the “encoding” comment is on line 2 of the source…

Thanks,
Hal

encoding: UTF-8

text = <<-EOF

Ein Schauer fat mich, Thrne folgt den Thrnen
Das strenge Herz es fhlt sich mild und weich…

Le coeur a ses raisons, que la raison ne connat point.

O gene umana, per volar s nata,
perch a poco vento cos cadi?
EOF

puts text
bash-3.2$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.4.0]
bash-3.2$
bash-3.2$ ruby try.rb
try.rb:6: invalid multibyte char (US-ASCII)
try.rb:4: syntax error, unexpected $end, expecting tSTRING_CONTENT or
tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
bash-3.2$

Note that the “encoding” comment is on line 2 of the source…

Thanks,
Hal

What is on line 1?
I get that error if line 1 is blank.
But if the encoding is on line 1, it works.

Harry

Ahh… I bet it has to be on the first nonblank line maybe?

H

On Wed, Sep 26, 2012 at 7:33 AM, Hal F. [email protected]
wrote:

Ahh… I bet it has to be on the first nonblank line maybe?

I think the magic comment needs to be on the first line.
Or it must be the second line if you have a shebang on the first line.

Harry