Navigation Menu

Skip to content

Commit

Permalink
implement ENCODING_SET() CRuby API
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Sansonetti committed May 1, 2011
1 parent bd12795 commit 3fce966
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions encoding.c
Expand Up @@ -525,10 +525,10 @@ rb_enc_to_index(VALUE enc)
void
rb_enc_set_index(VALUE obj, int encindex)
{
if (encindex < ENCODINGS_COUNT) {
return ;
assert(encindex >= 0 && encindex < ENCODINGS_COUNT);
if (TYPE(obj) == T_STRING) {
rb_str_force_encoding(obj, rb_encodings[encindex]);
}
rb_str_force_encoding(obj, rb_encodings[encindex]);
}

int
Expand Down
1 change: 1 addition & 0 deletions include/ruby/encoding.h
Expand Up @@ -17,6 +17,7 @@ extern "C" {
typedef struct rb_encoding rb_encoding;

#define ENCODING_GET(obj) (rb_enc_get_index((VALUE)obj))
#define ENCODING_SET(obj, idx) (rb_enc_set_index((VALUE)obj, idx))

int rb_enc_get_index(VALUE obj);
void rb_enc_set_index(VALUE obj, int encindex);
Expand Down

0 comments on commit 3fce966

Please sign in to comment.