Skip to content

Full Ruby String Encoding Support #94

@danielpclark

Description

@danielpclark

The rb_str_new method we have is good for making C strings in to Ruby string objects. From here we can go further and implement the string with rb_str_initialize to help also set the encoding.

VALUE
rb_str_initialize(VALUE str, const char *ptr, long len, rb_encoding *enc)
{
    STR_SET_LEN(str, 0);
    rb_enc_associate(str, enc);
    rb_str_cat(str, ptr, len);
    return str;
}

So I believe we should add the method rb_enc_associate to ruby_sys. We'll also likely need to implement encoding structs and have a C rb_encoding type mapped to ruru::Encoding.

typedef const OnigEncodingType rb_encoding;

The obvious places to look are string.c, encoding.c and encoding.h. But the OnigEncodingType (onigmo.h) is a C Regex thing for helping with encodings so I don't know how complex that would be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions