Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full Ruby String Encoding Support #94

Open
danielpclark opened this issue Mar 6, 2018 · 0 comments
Open

Full Ruby String Encoding Support #94

danielpclark opened this issue Mar 6, 2018 · 0 comments

Comments

@danielpclark
Copy link
Contributor

danielpclark commented Mar 6, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant