[#115884] Windows Ruby 3.2.2: Non-English character added to Windows Registry String Value — Jay Mav via ruby-core <ruby-core@...>
Hello,
3 messages
2023/12/24
[ruby-core:115792] [Ruby master Bug#20067] IO.pipe `int_enc` and `ext_enc` not working as documented?
From:
"nobu (Nobuyoshi Nakada) via ruby-core" <ruby-core@...>
Date:
2023-12-19 12:23:40 UTC
List:
ruby-core #115792
Issue #20067 has been updated by nobu (Nobuyoshi Nakada).
If the same encoding is specified for the internal and external encodings, it means that no encoding conversion will occur.
That's what the internal encoding `nil` means.
```
$ ruby -e 'File.open(IO::NULL, "r:ASCII-8BIT:ASCII-8BIT") {|f| p [f.internal_encoding, f.external_encoding]}'
[nil, #<Encoding:ASCII-8BIT>]
```
Regarding the external encoding of write-io, it feels something wrong a little.
----------------------------------------
Bug #20067: IO.pipe `int_enc` and `ext_enc` not working as documented?
https://bugs.ruby-lang.org/issues/20067#change-105737
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
>From the documentation:
> pipe(ext_enc, int_enc, **opts)
> If argument int_enc is given, it must be an Encoding object or encoding name string that specifies the internal encoding to be used; if argument ext_enc is also given, it must be an Encoding object or encoding name string that specifies the external encoding to be used.
Test script:
```ruby
ios = IO.pipe(Encoding::BINARY, Encoding::BINARY)
p [:internal, *ios.map(&:internal_encoding)]
p [:external, *ios.map(&:external_encoding)]
Encoding.default_internal = Encoding::UTF_8
Encoding.default_external = Encoding::UTF_8
ios = IO.pipe(Encoding::BINARY, Encoding::BINARY)
p [:internal, *ios.map(&:internal_encoding)]
p [:external, *ios.map(&:external_encoding)]
```
Actual output:
```
[:internal, nil, nil]
[:external, #<Encoding:ASCII-8BIT>, nil]
[:internal, nil, nil]
[:external, #<Encoding:ASCII-8BIT>, #<Encoding:UTF-8>]
```
Expected output:
```
[:internal, #<Encoding:ASCII-8BIT>, #<Encoding:ASCII-8BIT>]
[:external, #<Encoding:ASCII-8BIT>, #<Encoding:ASCII-8BIT>]
[:internal, #<Encoding:ASCII-8BIT>, #<Encoding:ASCII-8BIT>]
[:external, #<Encoding:ASCII-8BIT>, #<Encoding:ASCII-8BIT>]
```
Am I reading the documentation incorrectly, or is it just not working as claimed?
I tried on older versions, and it seems to have been like that all the way down to Ruby 1.9.
The only reliable way I found to have a "binary" pipe is to call `IO#binmode`.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/