"Brent Dax" <[EMAIL PROTECTED]> writes: Some comments on this
> =item C<Parrot_String Parrot_string_new(Parrot_Interp, char* bytes, > Parrot_Int len, Parrot_String enc)> > > Allocates a Parrot_String and sets it to the first C<len> bytes of > C<bytes>. C<enc> is the name of the encoding to use (e.g. "ASCII", > "UTF-8", "Shift-JIS"); if a case-insensitive match of this name doesn't > result in an encoding name that Parrot knows about, or if NULL is passed > as the encoding, the platform's default encoding is assumed.[1] Values > of NULL and 0 can be passed in for C<bytes> and C<len> if the user > desires an empty string. > > Note that it is rarely a good idea to not specify the encoding if you're > using C<bytes> and C<len>. Are you sure you want encoding to be a Parrot_String which is also encoded. I think it would be better if it were a NUL terminated C-String in native encoding. Parrot_string_new (interp, "foobar", 6, "UTF-8") vs. Parrot_string_new (interp, "foobar", 6, Parrot_string_new (interp, "UTF-8", 5, NULL)) or Parrot_string_new (interp, "foobar", 6, Parrot_string_from_cstring (interp, "UTF-8")) Or there have to be predefined Strings like Parrot_encoding_ASCII The C-level API should not be unnessesary hard. [...] > =item C<Parrot_String Parrot_string_copy_bytes(Parrot_Interp, > Parrot_String dest, char* bytes, Parrot_Int len, char* enc)> > > Sets C<dest> to the first C<len> bytes of C<bytes> and returns C<dest>. > C<enc> is taken to be the encoding of C<bytes>; the Parrot_String will > retain its original encoding. (Call C<Parrot_string_transcode> on the > Parrot_String first if you want to retain C<enc>.) Here enc is a native char *. Either way, specifing encoding should be done in one and only one way. > =item C<Parrot_String Parrot_string_encoding(Parrot_Interp, > Parrot_String str)> > > Returns the encoding of C<str> as a Parrot_String. If we go the way make encoding a C-String this should also be const char * Parrot_String_encoding (Parrot_Interp, Parrot_String) The life_time of this pointer can be specified as long as the interpreter lives (same as the Parrot_String) [...] > =item C<Parrot_PMC Parrot_pmc_new(Parrot_Interp, Parrot_String type)> > > Creates a new Parrot_PMC of the type C<type>. If C<type> is not a > case-insensitive match of any type already registered with Parrot, this > function will throw an exception. Ok, I think its a good thing to PMC-types in arbitary encodings. But it would be nice to have a convinience function Parrot_PMC Parrot_pmc_new_from_cstr (Parrot_Interp, const char *) [...] Just my EUR0.02 juergen -- Juergen Boemmels [EMAIL PROTECTED] Fachbereich Physik Tel: ++49-(0)631-205-2817 Universitaet Kaiserslautern Fax: ++49-(0)631-205-3906 PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F 23 F6 C7 2F 85 93 DD 47