HAL_90001
(HAL 9000)
1
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 faßt mich, Thräne folgt den Thränen
Das strenge Herz es fühlt sich mild und weich...
Le coeur a ses raisons, que la raison ne connaît 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$
Harry3
(Harry)
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
HAL_90001
(HAL 9000)
3
Ahh... I bet it has to be on the first nonblank line maybe?
H
···
On Tue, Sep 25, 2012 at 5:12 PM, Harry Kakueki <list.push@gmail.com> wrote:
>
> 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
Harry3
(Harry)
4
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
···
On Wed, Sep 26, 2012 at 7:33 AM, Hal Fulton <rubyhacker@gmail.com> wrote:
Ahh... I bet it has to be on the first nonblank line maybe?