If UTF-8 is the default, is there any point in '# encoding: UTF-8' magic comments?

I got it into my head they were needed, but
https://ruby-doc.org/core-3.0.1/Encoding.html#class-Encoding-label-Script+encoding
says it's been the default since V2_0

···

--
John Carter
Phone : (64)(3) 358 6639
Tait Electronics
PO Box 1645 Christchurch
New Zealand

--
This Communication is Confidential. We only send and receive email on the
basis of the terms set out at www.taitradio.com/email_disclaimer
<http://www.taitradio.com/email_disclaimer>

For Ruby, there isn't anymore. But for editors, there may be. Most editors
can find the right encoding I guess but some old editors may not. So it is
still conventional to add an encoding to source code files. Do I add? No.

John Carter <john.carter@taitradio.com>, 4 May 2021 Sal, 05:45 tarihinde
şunu yazdı:

···

I got it into my head they were needed, but
Class: Encoding (Ruby 3.0.1)
says it's been the default since V2_0

--
John Carter
Phone : (64)(3) 358 6639
Tait Electronics
PO Box 1645 Christchurch
New Zealand

------------------------------
This Communication is Confidential. We only send and receive email on the
basis of the terms set out at www.taitradio.com/email_disclaimer
------------------------------

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

--
https://ismailarilik.com

John,

Here you can find the "git blame" for Rubocop's style check that ensures
you don't have these comment any more. Maybe the Git comments will offer
some insight

Llinks:

- Style :: RuboCop Docs
- The Ruby Style Guide

···

-

Lee Hambley
http://lee.hambley.name/
+49 (0) 170 298 5667

On Tue, 4 May 2021 at 09:02, İsmail Arılık <arilik.ismail@gmail.com> wrote:

For Ruby, there isn't anymore. But for editors, there may be. Most editors
can find the right encoding I guess but some old editors may not. So it is
still conventional to add an encoding to source code files. Do I add? No.

John Carter <john.carter@taitradio.com>, 4 May 2021 Sal, 05:45 tarihinde
şunu yazdı:

I got it into my head they were needed, but
Class: Encoding (Ruby 3.0.1)
says it's been the default since V2_0

--
John Carter
Phone : (64)(3) 358 6639
Tait Electronics
PO Box 1645 Christchurch
New Zealand

------------------------------
This Communication is Confidential. We only send and receive email on the
basis of the terms set out at www.taitradio.com/email_disclaimer
------------------------------

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

--
https://ismailarilik.com

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

Thanks!

Sigh! I have just understood another source of my confusion....

   - unless you specify the -E command line option,
   - or explicitly set the encoding on every io open....
   - you get whatever darn external encoding your user happens to set with
   the LANG environment variable....
   - so when you read (unless you've set an internal encoding which might
   trigger a transcoding),
   - the string is encoding in whatever the environment variable said.

Which can, (on some strange users' box), result in much sadness if you do a
regexp match.

Not exactly robust if you expect a largish herd of cats to be running your
scripts.

I guess I had the happy (but incorrect) expectation that the default
external encoding would be the same as the script encoding (aka the default
regexp encoding).

I think I understand it all now... I think.

···

On Tue, May 4, 2021 at 8:49 PM Lee Hambley <lee.hambley@gmail.com> wrote:

John,

Here you can find the "git blame" for Rubocop's style check that ensures
you don't have these comment any more. Maybe the Git comments will offer
some insight

Llinks:

- Style :: RuboCop Docs
- The Ruby Style Guide
-
rubocop/lib/rubocop/cop/style/encoding.rb at master · rubocop/rubocop · GitHub

Lee Hambley
http://lee.hambley.name/
+49 (0) 170 298 5667

On Tue, 4 May 2021 at 09:02, İsmail Arılık <arilik.ismail@gmail.com> > wrote:

For Ruby, there isn't anymore. But for editors, there may be. Most
editors can find the right encoding I guess but some old editors may not.
So it is still conventional to add an encoding to source code files. Do I
add? No.

John Carter <john.carter@taitradio.com>, 4 May 2021 Sal, 05:45 tarihinde
şunu yazdı:

I got it into my head they were needed, but
Class: Encoding (Ruby 3.0.1)
says it's been the default since V2_0

--
John Carter
Phone : (64)(3) 358 6639
Tait Electronics
PO Box 1645 Christchurch
New Zealand

------------------------------
This Communication is Confidential. We only send and receive email on the
basis of the terms set out at www.taitradio.com/email_disclaimer
------------------------------

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

--
https://ismailarilik.com

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

--
John Carter
Phone : (64)(3) 358 6639
Tait Electronics
PO Box 1645 Christchurch
New Zealand

--
This Communication is Confidential. We only send and receive email on the
basis of the terms set out at www.taitradio.com/email_disclaimer
<http://www.taitradio.com/email_disclaimer>

I uncommented it, but I have a same question now?

···

Sent from my iPhone

On 05-May-2021, at 4:50 AM, John Carter <john.carter@taitradio.com> wrote:

Thanks!

Sigh! I have just understood another source of my confusion....
unless you specify the -E command line option,
or explicitly set the encoding on every io open....
you get whatever darn external encoding your user happens to set with the LANG environment variable....
so when you read (unless you've set an internal encoding which might trigger a transcoding),
the string is encoding in whatever the environment variable said.
Which can, (on some strange users' box), result in much sadness if you do a regexp match.

Not exactly robust if you expect a largish herd of cats to be running your scripts.

I guess I had the happy (but incorrect) expectation that the default external encoding would be the same as the script encoding (aka the default regexp encoding).

I think I understand it all now... I think.

On Tue, May 4, 2021 at 8:49 PM Lee Hambley <lee.hambley@gmail.com> wrote:
John,

Here you can find the "git blame" for Rubocop's style check that ensures you don't have these comment any more. Maybe the Git comments will offer some insight

Llinks:

- Style :: RuboCop Docs
- The Ruby Style Guide
- rubocop/lib/rubocop/cop/style/encoding.rb at master · rubocop/rubocop · GitHub

Lee Hambley
http://lee.hambley.name/
+49 (0) 170 298 5667

On Tue, 4 May 2021 at 09:02, İsmail Arılık <arilik.ismail@gmail.com> wrote:
For Ruby, there isn't anymore. But for editors, there may be. Most editors can find the right encoding I guess but some old editors may not. So it is still conventional to add an encoding to source code files. Do I add? No.

John Carter <john.carter@taitradio.com>, 4 May 2021 Sal, 05:45 tarihinde şunu yazdı:

I got it into my head they were needed, but https://ruby-doc.org/core-3.0.1/Encoding.html#class-Encoding-label-Script+encoding says it's been the default since V2_0

--
John Carter
Phone : (64)(3) 358 6639
Tait Electronics
PO Box 1645 Christchurch
New Zealand

This Communication is Confidential. We only send and receive email on the
basis of the terms set out at www.taitradio.com/email_disclaimer

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

--
https://ismailarilik.com

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

--
John Carter
Phone : (64)(3) 358 6639
Tait Electronics
PO Box 1645 Christchurch
New Zealand

This Communication is Confidential. We only send and receive email on the
basis of the terms set out at www.taitradio.com/email_disclaimer

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>