summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index f2611d29d6..909263357a 100644
--- a/hash.c
+++ b/hash.c
@@ -14,6 +14,7 @@
#include "ruby/ruby.h"
#include "ruby/st.h"
#include "ruby/util.h"
+#include "ruby/encoding.h"
#include <errno.h>
#ifdef __APPLE__
@@ -1367,10 +1368,13 @@ inspect_i(VALUE key, VALUE value, VALUE str)
VALUE str2;
if (key == Qundef) return ST_CONTINUE;
+ str2 = rb_inspect(key);
if (RSTRING_LEN(str) > 1) {
rb_str_cat2(str, ", ");
}
- str2 = rb_inspect(key);
+ else {
+ rb_enc_copy(str, str2);
+ }
rb_str_buf_append(str, str2);
OBJ_INFECT(str, str2);
rb_str_buf_cat2(str, "=>");