| 1 |
#include "ruby.h" |
| 2 |
#include "ruby/encoding.h" |
| 3 |
|
| 4 |
VALUE |
| 5 |
bug_str_enc_associate(VALUE str, VALUE enc) |
| 6 |
{ |
| 7 |
return rb_enc_associate(str, rb_to_encoding(enc)); |
| 8 |
} |
| 9 |
|
| 10 |
VALUE |
| 11 |
bug_str_encoding_index(VALUE self, VALUE str) |
| 12 |
{ |
| 13 |
int idx = rb_enc_get_index(str); |
| 14 |
return INT2NUM(idx); |
| 15 |
} |
| 16 |
|
| 17 |
void |
| 18 |
Init_string_enc_associate(VALUE klass) |
| 19 |
{ |
| 20 |
rb_define_method(klass, "associate_encoding!", bug_str_enc_associate, 1); |
| 21 |
rb_define_singleton_method(klass, "encoding_index", bug_str_encoding_index, 1); |
| 22 |
} |