Skip to content

Instantly share code, notes, and snippets.

@zenspider
Created August 13, 2026 02:27
Show Gist options
  • Select an option

  • Save zenspider/29642547ec147eafec2c3fc4db7c3982 to your computer and use it in GitHub Desktop.

Select an option

Save zenspider/29642547ec147eafec2c3fc4db7c3982 to your computer and use it in GitHub Desktop.
modified ruby.c
@@ -1708,9 +1708,12 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
case 'E':
if (!*++s && (!--argc || !(s = *++argv))) {
- rb_raise(rb_eRuntimeError, "missing argument for -E");
- }
- proc_encoding_option(opt, s, "-E");
+ printf("Available Encodings:\n\n");
+ // cheat! I can't call rb_eval_string at this point of init
+ opt->e_script = rb_str_new2("puts Encoding.constants.map { |k| Encoding.const_get(k) }.grep(Encoding).map(&:name).uniq.grep_v(/stateless|-SoftBank/).sort_by(&:downcase).join(', '); exit(1)");
+ opt->script = "-e";
+ } else
+ proc_encoding_option(opt, s, "-E");
break;
case 'U':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment