Add econv_get_encoding function

This commit is contained in:
S.H 2022-02-02 22:52:55 +09:00 committed by GitHub
parent d8c54bac4a
commit af10771045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2022-02-02 22:53:17 +09:00
Merged: https://github.com/ruby/ruby/pull/5509

Merged-By: nobu <nobu@ruby-lang.org>

View File

@ -3499,6 +3499,14 @@ check_econv(VALUE self)
return ec;
}
static VALUE
econv_get_encoding(rb_encoding *encoding)
{
if (!encoding)
return Qnil;
return rb_enc_from_encoding(encoding);
}
/*
* call-seq:
* ec.source_encoding -> encoding
@ -3509,9 +3517,7 @@ static VALUE
econv_source_encoding(VALUE self)
{
rb_econv_t *ec = check_econv(self);
if (!ec->source_encoding)
return Qnil;
return rb_enc_from_encoding(ec->source_encoding);
return econv_get_encoding(ec->source_encoding);
}
/*
@ -3524,9 +3530,7 @@ static VALUE
econv_destination_encoding(VALUE self)
{
rb_econv_t *ec = check_econv(self);
if (!ec->destination_encoding)
return Qnil;
return rb_enc_from_encoding(ec->destination_encoding);
return econv_get_encoding(ec->destination_encoding);
}
/*