Skip to content

Commit 3ea46e0

Browse files
committed
ensure symbols support encodings
1 parent 00fc49b commit 3ea46e0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ext/mysql2/result.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,15 @@ static VALUE rb_mysql_result_fetch_field(VALUE self, unsigned int idx, short int
114114

115115
field = mysql_fetch_field_direct(wrapper->result, idx);
116116
if (symbolize_keys) {
117+
VALUE colStr;
117118
char buf[field->name_length+1];
118119
memcpy(buf, field->name, field->name_length);
119120
buf[field->name_length] = 0;
120-
rb_field = ID2SYM(rb_intern(buf));
121+
colStr = rb_str_new2(buf);
122+
#ifdef HAVE_RUBY_ENCODING_H
123+
rb_enc_associate(colStr, rb_utf8_encoding());
124+
#endif
125+
rb_field = ID2SYM(colStr);
121126
} else {
122127
rb_field = rb_str_new(field->name, field->name_length);
123128
#ifdef HAVE_RUBY_ENCODING_H

0 commit comments

Comments
 (0)