Iñaki Baz Castillo
4/3/2009 7:01:00 PM
El Viernes 03 Abril 2009, I=C3=B1aki Baz Castillo escribi=C3=B3:
> El Viernes 03 Abril 2009, Andre Nathan escribi=C3=B3:
> > On Sat, 2009-04-04 at 01:39 +0900, I=C3=B1aki Baz Castillo wrote:
> > > Could I invoke the C "force_encoding()" function from the C code
> > > before returning the modified string? How to invoke it?
> >
> > You can call it as (untested):
> >
> > rb_funcall(str, rb_intern("force_encoding"), 1, rb_str_new2("utf-8"));
> >
> > I'm not sure how to make your multi-capitalize method do the right
> > thing, but maybe reading the source of rb_str_capitalize_bang in
> > string.c helps.
>
> Thanks a lot, I will check it.
Yes, rb_str_capitralize_bang handles a lot of stuf realted to encoding:
c =3D rb_enc_codepoint(s, send, enc);
if (rb_enc_islower(c, enc)) {
rb_enc_mbcput(rb_enc_toupper(c, enc), s, enc);
modify =3D 1;
}
s +=3D rb_enc_codelen(c, enc);
so this is the way :)
Thanks a lot.
=2D-=20
I=C3=B1aki Baz Castillo <ibc@aliax.net>