ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:120602] [Ruby master Misc#21025] What's the default encoding of `String.new`?
@ 2025-01-10 16:57 deivid via ruby-core
  2025-01-10 17:22 ` [ruby-core:120603] " Eregon (Benoit Daloze) via ruby-core
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: deivid via ruby-core @ 2025-01-10 16:57 UTC (permalink / raw)
  To: ruby-core; +Cc: deivid

Issue #21025 has been reported by deivid (David Rodríguez).

----------------------------------------
Misc #21025: What's the default encoding of `String.new`?
https://bugs.ruby-lang.org/issues/21025

* Author: deivid (David Rodríguez)
* Status: Open
----------------------------------------
In the documentation (https://docs.ruby-lang.org/en/3.4/encodings_rdoc.html#label-String+Encoding) I see a good explanation of default string encodings:

![](Captura%20de%20pantalla%202025-01-10%20a%20las%2017.53.06.png)

However, it does not mention `String.new` without an argument, which is the one case where I see inconsistent behavior.

```
irb(main):001> "".encoding
=> #<Encoding:UTF-8>
irb(main):002> String.new("").encoding
=> #<Encoding:UTF-8>
irb(main):003> String.new(a="").encoding
=> #<Encoding:UTF-8>
irb(main):004> String.new.encoding
=> #<Encoding:BINARY (ASCII-8BIT)>
```

Should this be documented or changed?

---Files--------------------------------
Captura de pantalla 2025-01-10 a las 17.53.06.png (139 KB)


-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:120603] [Ruby master Misc#21025] What's the default encoding of `String.new`?
  2025-01-10 16:57 [ruby-core:120602] [Ruby master Misc#21025] What's the default encoding of `String.new`? deivid via ruby-core
@ 2025-01-10 17:22 ` Eregon (Benoit Daloze) via ruby-core
  2025-01-10 18:13 ` [ruby-core:120604] " deivid via ruby-core
  2025-01-10 19:48 ` [ruby-core:120605] " deivid via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2025-01-10 17:22 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #21025 has been updated by Eregon (Benoit Daloze).


It's just a documentation bug.
It's always BINARY for `String.new` without args.

----------------------------------------
Misc #21025: What's the default encoding of `String.new`?
https://bugs.ruby-lang.org/issues/21025#change-111431

* Author: deivid (David Rodríguez)
* Status: Open
----------------------------------------
In the documentation (https://docs.ruby-lang.org/en/3.4/encodings_rdoc.html#label-String+Encoding) I see a good explanation of default string encodings:

![](Captura%20de%20pantalla%202025-01-10%20a%20las%2017.53.06.png)

However, it does not mention `String.new` without an argument, which is the one case where I see inconsistent behavior.

```
irb(main):001> "".encoding
=> #<Encoding:UTF-8>
irb(main):002> String.new("").encoding
=> #<Encoding:UTF-8>
irb(main):003> String.new(a="").encoding
=> #<Encoding:UTF-8>
irb(main):004> String.new.encoding
=> #<Encoding:BINARY (ASCII-8BIT)>
```

Should this be documented or changed?

---Files--------------------------------
Captura de pantalla 2025-01-10 a las 17.53.06.png (139 KB)


-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:120604] [Ruby master Misc#21025] What's the default encoding of `String.new`?
  2025-01-10 16:57 [ruby-core:120602] [Ruby master Misc#21025] What's the default encoding of `String.new`? deivid via ruby-core
  2025-01-10 17:22 ` [ruby-core:120603] " Eregon (Benoit Daloze) via ruby-core
@ 2025-01-10 18:13 ` deivid via ruby-core
  2025-01-10 19:48 ` [ruby-core:120605] " deivid via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: deivid via ruby-core @ 2025-01-10 18:13 UTC (permalink / raw)
  To: ruby-core; +Cc: deivid

Issue #21025 has been updated by deivid (David Rodríguez).


Cool, thanks for the info, I'll create a PR to improve the documentation.

----------------------------------------
Misc #21025: What's the default encoding of `String.new`?
https://bugs.ruby-lang.org/issues/21025#change-111432

* Author: deivid (David Rodríguez)
* Status: Open
----------------------------------------
In the documentation (https://docs.ruby-lang.org/en/3.4/encodings_rdoc.html#label-String+Encoding) I see a good explanation of default string encodings:

![](Captura%20de%20pantalla%202025-01-10%20a%20las%2017.53.06.png)

However, it does not mention `String.new` without an argument, which is the one case where I see inconsistent behavior.

```
irb(main):001> "".encoding
=> #<Encoding:UTF-8>
irb(main):002> String.new("").encoding
=> #<Encoding:UTF-8>
irb(main):003> String.new(a="").encoding
=> #<Encoding:UTF-8>
irb(main):004> String.new.encoding
=> #<Encoding:BINARY (ASCII-8BIT)>
```

Should this be documented or changed?

---Files--------------------------------
Captura de pantalla 2025-01-10 a las 17.53.06.png (139 KB)


-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:120605] [Ruby master Misc#21025] What's the default encoding of `String.new`?
  2025-01-10 16:57 [ruby-core:120602] [Ruby master Misc#21025] What's the default encoding of `String.new`? deivid via ruby-core
  2025-01-10 17:22 ` [ruby-core:120603] " Eregon (Benoit Daloze) via ruby-core
  2025-01-10 18:13 ` [ruby-core:120604] " deivid via ruby-core
@ 2025-01-10 19:48 ` deivid via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: deivid via ruby-core @ 2025-01-10 19:48 UTC (permalink / raw)
  To: ruby-core; +Cc: deivid

Issue #21025 has been updated by deivid (David Rodríguez).


I created https://github.com/ruby/ruby/pull/12548 for this.

----------------------------------------
Misc #21025: What's the default encoding of `String.new`?
https://bugs.ruby-lang.org/issues/21025#change-111433

* Author: deivid (David Rodríguez)
* Status: Open
----------------------------------------
In the documentation (https://docs.ruby-lang.org/en/3.4/encodings_rdoc.html#label-String+Encoding) I see a good explanation of default string encodings:

![](Captura%20de%20pantalla%202025-01-10%20a%20las%2017.53.06.png)

However, it does not mention `String.new` without an argument, which is the one case where I see inconsistent behavior.

```
irb(main):001> "".encoding
=> #<Encoding:UTF-8>
irb(main):002> String.new("").encoding
=> #<Encoding:UTF-8>
irb(main):003> String.new(a="").encoding
=> #<Encoding:UTF-8>
irb(main):004> String.new.encoding
=> #<Encoding:BINARY (ASCII-8BIT)>
```

Should this be documented or changed?

---Files--------------------------------
Captura de pantalla 2025-01-10 a las 17.53.06.png (139 KB)


-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-10 19:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-10 16:57 [ruby-core:120602] [Ruby master Misc#21025] What's the default encoding of `String.new`? deivid via ruby-core
2025-01-10 17:22 ` [ruby-core:120603] " Eregon (Benoit Daloze) via ruby-core
2025-01-10 18:13 ` [ruby-core:120604] " deivid via ruby-core
2025-01-10 19:48 ` [ruby-core:120605] " deivid via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).