Project

General

Profile

Actions

Feature #22244

open

`ruby -UU` should set both internal and external, `ruby -E` should print encoding list

Feature #22244: `ruby -UU` should set both internal and external, `ruby -E` should print encoding list

Added by zenspider (Ryan Davis) 2 months ago. Updated 2 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:126381]

Description

10004 $ env -u LANG ruby -U -e 'pp [Encoding.default_internal, Encoding.default_external]'
[#<Encoding:UTF-8>, #<Encoding:US-ASCII>]

10005 $ env -u LANG ruby -EUTF-8 -e 'pp [...]'
[nil, #<Encoding:UTF-8>]

10006 $ env -u LANG ruby -EUTF-8 -U -e 'pp [...]'
[#<Encoding:UTF-8>, #<Encoding:UTF-8>]

10007 $ env -u LANG ruby -EUTF-8:UTF-8 -e 'pp [...]'
[#<Encoding:UTF-8>, #<Encoding:UTF-8>]

10008 $ env -u LANG ruby -UU -e 'pp [...]'
[#<Encoding:UTF-8>, #<Encoding:US-ASCII>]

I think the option processing of encodings is VERY poorly documented and frustrating to try to use.

  1. --help doesn't list -U. (The man page does)
  2. --help for -E doesn't provide a means to get a list of available encoding names (same with manpage), leading me to try U, UTF8, UTF_8, before finding UTF-8. ruby -E could just print them all out.
  3. WHY NOT take UTF8 or UTF_8 (since that's the class name)?
  4. Please consider -UU to mean -EUTF-8:UTF-8

Updated by zenspider (Ryan Davis) 2 months ago Actions #1 [ruby-core:126385]

Quick and dirty patch: https://github.com/ruby/ruby/compare/master...zenspider:ruby:zenspider__encodings?expand=1

This is rough. I'm faking an eval early in the option handling. There is probably a better C way to do this. It is probably failing tests.

But the idea is there.

Updated by zenspider (Ryan Davis) 7 days ago Actions #3 [ruby-core:127064]

This is all greened up. Sorry for taking so long!

Updated by zenspider (Ryan Davis) 2 days ago Actions #4 [ruby-core:127129]

@matz (Yukihiro Matsumoto) any chance I can get this enhancement into 4.1? I think it helps usability a fair amount:

10001 $ ./build/miniruby tool/runruby.rb --extout=build --archdir=build  -- -E
Available Encodings:

    ASCII-8BIT, Big5, Big5-HKSCS, Big5-UAO, CESU-8, CP850, CP852, CP855,
    CP949, CP950, CP951, CP50220, CP50221, CP51932, Emacs-Mule, EUC-JIS-2004,
    EUC-JP, EUC-KR, EUC-TW, eucJP-ms, GB1988, GB2312, GB12345, GB18030, GBK,
    IBM037, IBM437, IBM720, IBM737, IBM775, IBM852, IBM855, IBM857, IBM860,
    IBM861, IBM862, IBM863, IBM864, IBM865, IBM866, IBM869, ISO-2022-JP,
    ISO-2022-JP-2, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4,
    ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10,
    ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16, KOI8-R,
    KOI8-U, macCentEuro, macCroatian, macCyrillic, macGreek, macIceland,
    MacJapanese, macRoman, macRomania, macThai, macTurkish, macUkraine,
    Shift_JIS, TIS-620, US-ASCII, UTF8-MAC, UTF-7, UTF-8, UTF-16, UTF-16BE,
    UTF-16LE, UTF-32, UTF-32BE, UTF-32LE, Windows-31J, Windows-874,
    Windows-1250, Windows-1251, Windows-1252, Windows-1253, Windows-1254,
    Windows-1255, Windows-1256, Windows-1257, Windows-1258

Updated by Anonymous 2 days ago Actions #5

Hello Ryan,

I suggest you add your issue to [Ruby Misc#22417] DevMeeting-2026-11-12.
This is the best way to get attention and a decision from @matz (Yukihiro Matsumoto).

Regards, Martin.

On 2026-10-16 04:00, zenspider (Ryan Davis) via ruby-core wrote:

Issue #22244 has been updated by zenspider (Ryan Davis).

@matz (Yukihiro Matsumoto) any chance I can get this enhancement into 4.1? I think it helps usability a fair amount:

10001 $ ./build/miniruby tool/runruby.rb --extout=build --archdir=build  -- -E
Available Encodings:

     ASCII-8BIT, Big5, Big5-HKSCS, Big5-UAO, CESU-8, CP850, CP852, CP855,
     CP949, CP950, CP951, CP50220, CP50221, CP51932, Emacs-Mule, EUC-JIS-2004,
     EUC-JP, EUC-KR, EUC-TW, eucJP-ms, GB1988, GB2312, GB12345, GB18030, GBK,
     IBM037, IBM437, IBM720, IBM737, IBM775, IBM852, IBM855, IBM857, IBM860,
     IBM861, IBM862, IBM863, IBM864, IBM865, IBM866, IBM869, ISO-2022-JP,
     ISO-2022-JP-2, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4,
     ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10,
     ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16, KOI8-R,
     KOI8-U, macCentEuro, macCroatian, macCyrillic, macGreek, macIceland,
     MacJapanese, macRoman, macRomania, macThai, macTurkish, macUkraine,
     Shift_JIS, TIS-620, US-ASCII, UTF8-MAC, UTF-7, UTF-8, UTF-16, UTF-16BE,
     UTF-16LE, UTF-32, UTF-32BE, UTF-32LE, Windows-31J, Windows-874,
     Windows-1250, Windows-1251, Windows-1252, Windows-1253, Windows-1254,
     Windows-1255, Windows-1256, Windows-1257, Windows-1258

Feature #22244: ruby -UU should set both internal and external, ruby -E should print encoding list
https://bugs.ruby-lang.org/issues/22244#change-119533

  • Author: zenspider (Ryan Davis)
  • Status: Open

10004 $ env -u LANG ruby -U -e 'pp [Encoding.default_internal, Encoding.default_external]'
[#<Encoding:UTF-8>, #<Encoding:US-ASCII>]

10005 $ env -u LANG ruby -EUTF-8 -e 'pp [...]'
[nil, #<Encoding:UTF-8>]

10006 $ env -u LANG ruby -EUTF-8 -U -e 'pp [...]'
[#<Encoding:UTF-8>, #<Encoding:UTF-8>]

10007 $ env -u LANG ruby -EUTF-8:UTF-8 -e 'pp [...]'
[#<Encoding:UTF-8>, #<Encoding:UTF-8>]

10008 $ env -u LANG ruby -UU -e 'pp [...]'
[#<Encoding:UTF-8>, #<Encoding:US-ASCII>]

I think the option processing of encodings is VERY poorly documented and frustrating to try to use.

  1. --help doesn't list -U. (The man page does)
  2. --help for -E doesn't provide a means to get a list of available encoding names (same with manpage), leading me to try U, UTF8, UTF_8, before finding UTF-8. ruby -E could just print them all out.
  3. WHY NOT take UTF8 or UTF_8 (since that's the class name)?
  4. Please consider -UU to mean -EUTF-8:UTF-8

Actions

Also available in: PDF Atom