[#109095] [Ruby master Misc#18888] Migrate ruby-lang.org mail services to Google Domains and Google Workspace — "shugo (Shugo Maeda)" <noreply@...>
Issue #18888 has been reported by shugo (Shugo Maeda).
16 messages
2022/06/30
[ruby-core:108886] [Ruby master Bug#18827] `__ENCODING__` is not set to the source encoding when saving script lines
From:
"nobu (Nobuyoshi Nakada)" <noreply@...>
Date:
2022-06-14 02:33:07 UTC
List:
ruby-core #108886
Issue #18827 has been reported by nobu (Nobuyoshi Nakada).
----------------------------------------
Bug #18827: `__ENCODING__` is not set to the source encoding when saving script lines
https://bugs.ruby-lang.org/issues/18827
* Author: nobu (Nobuyoshi Nakada)
* Status: Open
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Backport: 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED
----------------------------------------
`__ENCODING__` should respect the encoding of the given source code.
```shell-session
$ ruby -Ke -e 'p __ENCODING__'
#<Encoding:EUC-JP>
```
```ruby
p eval("__ENCODING__".encode("euc-jp")) #=> #<Encoding:EUC-JP>
```
But it is ignored when `SCRIPT_LINES__` is set.
```shell-session
$ cat script_lines.rb
SCRIPT_LINES__ = {}
$ ruby -r./script_lines.rb -Ke -e 'p __ENCODING__'
#<Encoding:UTF-8>
```
Also similar when `keep_script_lines` is true.
```ruby
pp RubyVM::AbstractSyntaxTree.parse("__ENCODING__".encode("euc-jp"), keep_script_lines: true)
#=> (SCOPE@1:0-1:12 tbl: [] args: nil body: (LIT@1:0-1:12 #<Encoding:UTF-8>))
```
--
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>