End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
NKF.guess
NKF.guess(str) => encoding
ext/nkf/nkf.c
View on GitHub ↗
static VALUE
rb_nkf_guess(VALUE obj, VALUE src)
{
reinit();
input_ctr = 0;
input = (unsigned char *)StringValuePtr(src);
i_len = RSTRING_LENINT(src);
guess_f = TRUE;
kanji_convert( NULL );
guess_f = FALSE;
return rb_enc_from_encoding(rb_nkf_enc_get(get_guessed_code()));
}
Returns guessed encoding of str by nkf routine.