Method: String#encoding

Defined in:
encoding.c

#encodingEncoding

Returns the Encoding object that represents the encoding of obj.

Returns:

[View source]

1201
1202
1203
1204
1205
1206
1207
1208
1209
# File 'encoding.c', line 1201

VALUE
rb_obj_encoding(VALUE obj)
{
    int idx = rb_enc_get_index(obj);
    if (idx < 0) {
	rb_raise(rb_eTypeError, "unknown encoding");
    }
    return rb_enc_from_encoding_index(idx & ENC_INDEX_MASK);
}