[#100689] [Ruby master Feature#17303] Make webrick to bundled gems or remove from stdlib — hsbt@...

Issue #17303 has been reported by hsbt (Hiroshi SHIBATA).

11 messages 2020/11/02

[#100715] [Ruby master Bug#17306] TestGCCompact#test_ast_compacts test failures — v.ondruch@...

Issue #17306 has been reported by vo.x (Vit Ondruch).

11 messages 2020/11/05

[#100720] [Ruby master Feature#17307] A way to mark C extensions as thread-safe, Ractor-safe, or unsafe — eregontp@...

Issue #17307 has been reported by Eregon (Benoit Daloze).

22 messages 2020/11/05

[#100744] [Ruby master Bug#17310] Closed ractors should die — marcandre-ruby-core@...

Issue #17310 has been reported by marcandre (Marc-Andre Lafortune).

12 messages 2020/11/08

[#100753] [Ruby master Feature#17312] New methods in Enumerable and Enumerator::Lazy: flatten, product, compact — zverok.offline@...

Issue #17312 has been reported by zverok (Victor Shepelev).

11 messages 2020/11/09

[#100763] [Ruby master Feature#17314] Provide a way to declare visibility of attributes defined by attr* methods in a single expression — radek.bulat@...

Issue #17314 has been reported by radarek (RadosナBw BuナBt).

17 messages 2020/11/10

[#100777] [Ruby master Feature#17316] On memoization — sawadatsuyoshi@...

Issue #17316 has been reported by sawa (Tsuyoshi Sawada).

18 messages 2020/11/11

[#100788] [Ruby master Misc#17319] Rename Random::urandom to os_random and document random data sources — zofrex@...

Issue #17319 has been reported by zofrex (James Sanderson).

11 messages 2020/11/11

[#100807] [Ruby master Feature#17322] Deprecate `Random::DEFAULT` and introduce `Random.default()` method to provide Ractor-supported default random generator — ko1@...

Issue #17322 has been reported by ko1 (Koichi Sasada).

14 messages 2020/11/12

[#100816] [Ruby master Feature#17323] Ractor::LVar to provide ractor-local storage — ko1@...

Issue #17323 has been reported by ko1 (Koichi Sasada).

19 messages 2020/11/12

[#100849] [Ruby master Feature#17325] Adds Fiber#cancel, which forces a Fiber to break/return — nicholas.evans@...

Issue #17325 has been reported by nevans (Nicholas Evans).

17 messages 2020/11/14

[#100852] [Ruby master Feature#17326] Add Kernel#must! to the standard library — zimmerman.jake@...

Issue #17326 has been reported by jez (Jake Zimmerman).

24 messages 2020/11/14

[#100858] [Ruby master Feature#17327] The Queue constructor should take an initial set of items — chris@...

Issue #17327 has been reported by chrisseaton (Chris Seaton).

10 messages 2020/11/15

[#100897] [Ruby master Feature#17330] Object#non — zverok.offline@...

Issue #17330 has been reported by zverok (Victor Shepelev).

21 messages 2020/11/17

[#100925] [Ruby master Feature#17331] Let Fiber#raise work with transferring fibers — nicholas.evans@...

Issue #17331 has been reported by nevans (Nicholas Evans).

12 messages 2020/11/18

[#100930] [Ruby master Feature#17333] Enumerable#many? — masafumi.o1988@...

Issue #17333 has been reported by okuramasafumi (Masafumi OKURA).

10 messages 2020/11/18

[#100971] [Ruby master Bug#17337] Don't embed Ruby build time configuration into Ruby — v.ondruch@...

Issue #17337 has been reported by vo.x (Vit Ondruch).

16 messages 2020/11/20

[#100999] [Ruby master Feature#17339] Semantic grouping on BigDecimal#to_s — co.chuma@...

Issue #17339 has been reported by chumaltd (Takahiro Chuma).

9 messages 2020/11/21

[#101071] [Ruby master Feature#17342] Hash#fetch_set — hunter_spawn@...

Issue #17342 has been reported by MaxLap (Maxime Lapointe).

26 messages 2020/11/25

[#101093] [Ruby master Misc#17346] DevelopersMeeting20201210Japan — mame@...

Issue #17346 has been reported by mame (Yusuke Endoh).

17 messages 2020/11/26

[#101141] [Ruby master Bug#17354] Module#const_source_location is misleading for constants awaiting autoload — tom@...

Issue #17354 has been reported by tomstuart (Tom Stuart).

21 messages 2020/11/29

[#101143] [Ruby master Feature#17355] Or-patterns (pattern matching like Foo(x) | Bar(x)) — fg@...

Issue #17355 has been reported by decuplet (Nikita Shilnikov).

8 messages 2020/11/29

[#101153] [Ruby master Feature#17356] Alignment of memory allocated through Fiddle struct's malloc — andrea.ribuoli@...

Issue #17356 has been reported by AndreaRibuoli (Andrea Ribuoli).

8 messages 2020/11/30

[ruby-core:101122] [Ruby master Feature#16604] Set default for Encoding.default_external to UTF-8 on Windows

From: larskanis@...
Date: 2020-11-27 10:28:31 UTC
List: ruby-core #101122
Issue #16604 has been updated by larskanis (Lars Kanis).


Both Appveyor and Github-Actions use `Encoding.default_external = UTF-8` in their default ruby versions on Windows. [Appveyor sets this](https://ci.appveyor.com/project/larskanis/github-action-test/build/job/v6vgrdu9iprxu6x3) per `RUBYOPT=-Eutf-8` and Github-Actions goes [a step further](https://github.com/larskanis/github-action-test/runs/1463089885?check_suite_focus=true#step:4:12) and sets it per `chcp 65001`, which also changes the pseudo encoding `locale` to UTF-8.

So `Encoding.default_external = UTF-8` is already the de facto standard and ruby just need to follow the standard. 

----------------------------------------
Feature #16604: Set default for Encoding.default_external to UTF-8 on Windows
https://bugs.ruby-lang.org/issues/16604#change-88801

* Author: larskanis (Lars Kanis)
* Status: Open
* Priority: Normal
----------------------------------------
This issue is related to https://bugs.ruby-lang.org/issues/13488 where we already discussed the topic and postponed the change for ruby-3. A patch is here: https://github.com/ruby/ruby/pull/2877

## What should be changed?

Currently `Encoding.default_external` is initialized to the local console encoding of the Windows installation unless changed per option `-E`. This is e.g. cp850 for Western Europe. It should be changed to UTF-8.

The above patch only changes the default for `Encoding.default_external`. It can still be overwritten per command line option `-Elocale` or in ruby code.

## Reasons for the change

Changing to UTF-8 fixes various inconsistencies within ruby and with external tools. A very common case is writing a non-ASCII text to a file. It writes the string content as its binary representation, which is usually UTF-8, since this is the default ruby source encoding. But reading the content back, tags the string with the wrong encoding leading to mojibakes.

```
s = "テ、テカテシ"
File.write("x", s)   # => 6 bytes
File.read("x") == s  # => true in irb but false in .rb file
```

As noted in the last line, the result in `irb` is different from regular .rb files, since it already sets `Encoding.default_external = "utf-8"` on it's own. This is another inconsistency with the current default.

Another issue is that many non-asian regions have distinct legacy encodings for OEM code page (aka `Encoding.find('locale')` ) and ANSI code page (aka `Encoding.find('filesystem')` ), so that a file written in current default external encoding `Encoding.find('locale')` is not properly interpret in Windows GUI tools like notepad. It is therefore uncommon to store files in OEM-ANSI encoding and doing so is almost certainly wrong.

RubyInstaller ships the MSYS2 environment, which defaults to UTF-8 as well.

Powershell made the switch to UTF-8 (without BOM) in [Powershell-6.0](https://docs.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-core-60?view=powershell-7#default-encoding-is-utf-8-without-a-bom-except-for-new-modulemanifest) and even more in 6.1.

## Will it work?

Yes. RubyInstaller provided a checkbox for `RUBYOPT=-Eutf-8` since version 2.4. This checkbox was disabled at first, but since RubyInstaller-2.7.0 this checkbox is [enabled per default](https://rubyinstaller.org/2020/01/05/rubyinstaller-2.7.0-1-released.html). So UTF-8 as the default external encoding is the expected encoding for most of the people on Windows, now.

However setting `RUBYOPT` per installer is obtrusive and doesn't work with a 7z archive distribution. I would like to remove this hack starting with ruby-3.0.

## Alternatives

Changing the default of `Encoding.default_external` to UTF-8 is a trade-off. It doesn't fit to every case, but in my experience this is the best overall option. And it's just the default for the default, so that it can be overwritten in many ways.

There are some alternatives to it:

Changing the Windows console to code page 65001:
 * The Windows implementation of 65001 is buggy in the console. I didn't verify it lately but `chcp 65001` didn't work reliable years ago.
 * It is not the default and input methods like IME are incompatible.
 * It sets `locale` to UTF-8, so that the native console encoding isn't easily available.

Setting `Encoding.default_internal` in addition:
 * This triggers transcoding of output strings, which is not enabled on other systems, causing unexpected results and incompatibilities.

Change ruby to use `Encoding.find("filesystem")` as encoding for file operations:
 * That would fix the compatibility with some builtin Windows tools, but doesn't fix encoding issues due to increased use of UTF-8.

## What doesn't change?

Please note that changing `Encoding.default_external` doesn't affect file or IO **output**, unless `Encoding.default_internal` is set as well (which is not the default).

Also "locale" and "filesystem" pseudo encodings don't change. Both can still be used explicit in cases where these encodings are required.

The patch is currently about Windows only, because I would like to focus on that question for now. Possibly it's a subsequent question whether Encoding.default_external should default to UTF-8 on all operating systems or at least in case of `LANG=C` locale (which currently triggers US-ASCII).




-- 
https://bugs.ruby-lang.org/

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

In This Thread