summaryrefslogtreecommitdiffstats
path: root/ruby.c
diff options
context:
space:
mode:
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/ruby.c b/ruby.c
index 8b14419e7..8fa0c445b 100644
--- a/ruby.c
+++ b/ruby.c
@@ -843,6 +843,7 @@ process_options(VALUE arg)
char **argv = opt->argv;
NODE *tree = 0;
VALUE parser;
+ VALUE encoding;
const char *s;
int i = proc_options(argc, argv, opt);
@@ -970,7 +971,13 @@ process_options(VALUE arg)
}
}
- rb_set_primary_encoding(rb_parser_encoding(parser));
+ if (opt->enc_index >= 0) {
+ encoding = rb_enc_from_encoding(rb_enc_from_index(opt->enc_index));
+ }
+ else {
+ encoding = rb_parser_encoding(parser);
+ }
+ rb_set_primary_encoding(encoding);
return (VALUE)tree;
}