On Wed, Nov 17, 2010 at 12:10 PM, Clifford Heath <no / spam.please.net> wrote:
> Ammar Ali wrote:
>>
>> On Wed, Nov 17, 2010 at 12:20 AM, Clifford Heath <no / spam.please.net>
>> wrote:
>>>
>>> ruby --help lists -E, which doesn't seem to work as advertised,
>>> but not -K, which does what I wanted. Can someone please check
>>> that the source code and the help message coincide?
>>
>> I'm not sure what you mean by work as advertised, but I would like to
>> note that the syntax for -E is different that of -K; it takes the full
>> encoding name, case-insensitive:
>>
>> ruby -Eutf-8:utf-8
>> ruby -Eascii:utf-8
>>
>> Does that do what you except?
>
> No, it still complains "invalid multibyte char (US-ASCII)" on
> a valid UTF-8 character, in a UTF-8 file having no Unicode BOM.
>
> Also, the help implies that you can set just the external encoding
> without the internal encoding, which I did, since I could care less
> which internal encoding Ruby uses.

I believe you're misunderstanding what internal and external encodings
represent. For a thorough explanation, see http://goo.gl/iUBCX .
Briefly, if your source file contains non-ASCII characters the
recommended approach is to declare a source encoding via a magic
comment. In this case, your file should begin with "# coding: utf-8".
If you insist on using `-K`, try `ruby -KU` instead.