Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rb_enc_get() to retrieve encoding type #685

Merged
merged 1 commit into from Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions ext/oj/dump.c
Expand Up @@ -708,10 +708,10 @@ void oj_write_obj_to_stream(VALUE obj, VALUE stream, Options copts) {
}

void oj_dump_str(VALUE obj, int depth, Out out, bool as_ok) {
rb_encoding *enc = rb_to_encoding(rb_obj_encoding(obj));
rb_encoding *enc = rb_enc_get(obj);

if (rb_utf8_encoding() != enc) {
obj = rb_str_conv_enc(obj, enc, rb_utf8_encoding());
if (oj_utf8_encoding != enc) {
obj = rb_str_conv_enc(obj, enc, oj_utf8_encoding);
}
oj_dump_cstr(RSTRING_PTR(obj), (int)RSTRING_LEN(obj), 0, 0, out);
}
Expand Down
6 changes: 3 additions & 3 deletions ext/oj/parse.c
Expand Up @@ -964,10 +964,10 @@ static VALUE protect_parse(VALUE pip) {
extern int oj_utf8_index;

static void oj_pi_set_input_str(ParseInfo pi, volatile VALUE *inputp) {
rb_encoding *enc = rb_to_encoding(rb_obj_encoding(*inputp));
rb_encoding *enc = rb_enc_get(*inputp);

if (rb_utf8_encoding() != enc) {
*inputp = rb_str_conv_enc(*inputp, enc, rb_utf8_encoding());
if (oj_utf8_encoding != enc) {
*inputp = rb_str_conv_enc(*inputp, enc, oj_utf8_encoding);
}
pi->json = RSTRING_PTR(*inputp);
pi->end = pi->json + RSTRING_LEN(*inputp);
Expand Down