| parrotcode: Parrot Strings | |
| Contents | C | 

src/string.c - Parrot Strings

This file implements the non-ICU parts of the Parrot string subsystem.
Note that bufstart and buflen are used by the memory subsystem.
The string functions may only use buflen to determine,
if there is some space left beyond bufused.
This is the only valid usage of these two data members,
beside setting bufstart/buflen for external strings.

void Parrot_unmake_COWSTRING *Parrot_make_COW_referenceSTRING *Parrot_reuse_COW_referenceSTRING *string_set
Creation, enlargement, etc.
void string_initvoid string_deinitUINTVAL string_capacitySTRING *string_make_emptyconst CHARSET *string_rep_compatible  ascii <op> utf8 => utf8
                  => ascii, B<if> C<STRING *b> has ascii chars only.
STRING *string_appendSTRING *string_from_cstringconst char *string_primary_encoding_for_representationSTRING *const_stringSTRING *string_makelen bytes of string data read from buffer.charset_name specifies the string's representation. The currently recognised values are:    'iso-8859-1'
    'ascii'
    'binary'
    'unicode'
unicode implies the utf-8 encoding, and the other three assume fixed-8 encoding.charset is unspecified the default charset 'ascii' will be used.flags is optionally one or more PObj_* flags OR-ed together.STRING *string_make_directSTRING *string_grow
UINTVAL string_lengthINTVAL string_indexINTVAL string_str_indexstart. The return value is a (0 based) offset in characters, not bytes. If second string is not found in the first string, then return -1.INTVAL string_ordSTRING *string_chrSTRING *string_copy
INTVAL string_compute_strlenINTVAL string_max_bytesSTRING *string_concatNULL, then a copy of the non-NULL string is returned. If both strings are NULL, then a new zero-length string is created and returned.STRING *string_repeatSTRING *string_substrlength from offset from the specified Parrot string and stores it in **d, allocating memory if necessary. The substring is also returned.STRING *string_replace    substr EXPR, OFFSET, LENGTH, REPLACEMENT
length characters from offset in the first Parrot string with the second Parrot string, returning what was replaced.STRING *string_chopnn characters of the specified Parrot string. If n is negative, cuts the string after +n characters. The returned string is a copy of the one passed in.void string_chopn_inplacen characters of the specified Parrot string. If n is negative, cuts the string after +n characters. The string passed in is modified and returned.INTVAL string_compareINTVAL string_equalstatic void make_writablelen. The representation argument is required in case a new Parrot string has to be created.STRING *string_bitwise_andAND on two Parrot string, performing type and encoding conversions if necessary. If the second string is not NULL then it is reused, otherwise a new Parrot string is created.STRING *string_bitwise_orOR on two Parrot strings, performing type and encoding conversions if necessary. If the third string is not NULL then it is reused, otherwise a new Parrot string is created.STRING *string_bitwise_xorXOR on two Parrot strings, performing type and encoding conversions if necessary. If the second string is not NULL then it is reused, otherwise a new Parrot string is created.STRING *string_bitwise_notNOT on a Parrot string. If the second string is not NULL then it is reused, otherwise a new Parrot string is created.INTVAL string_bool0, "" or "0".STRING *string_nprintfParrot_snprintf() except that it writes to and returns a Parrot string.bytelen does not include space for a (non-existent) trailing '\0'. dest may be a NULL pointer, in which case a new native string will be created. If bytelen is 0, the behaviour becomes more sprintf-ish than snprintf-like. bytelen is measured in the encoding of *dest.STRING *string_printfINTVAL string_to_int    sign            =  '+' | '-'
    digit           =  "Any code point considered a digit by the chartype"
    indicator       =  'e' | 'E'
    digits          =  digit [digit]...
    decimal-part    =  digits '.' [digits] | ['.'] digits
    exponent-part   =  indicator [sign] digits
    numeric-string  =  [sign] decimal-part [exponent-part]
FLOATVAL string_to_numstring_to_int() except that a floating-point value is returned.STRING *string_from_intSTRING *string_from_numchar *string_to_cstringstring_cstring_free() to free the string. Failure to do this will result in a memory leak.void string_cstring_freestring_to_cstring().void string_pinvoid string_unpinstring_pin() so that the string once again uses managed memory.size_t string_hashs->hashval.STRING *string_escape_stringstring_unescape_cstring can handle are esacped as \x, as well as a double quote character. Other control chars and codepoints < 0x100 are escaped as \xhh, codepoints up to 0xffff, as \uhhhh, and codepoints greater than this as \x{hh...hh}.STRING *string_escape_string_delimitedSTRING *string_unescape_cstring  \xhh        1..2 hex digits
  \ooo        1..3 oct digits
  \cX         control char X
  \x{h..h}    1..8 hex digits
  \uhhhh      4 hex digits
  \Uhhhhhhhh  8 hex digits
  \a, \b, \t, \n, \v, \f, \r, \e
STRING *string_upcasevoid string_upcase_inplaceSTRING *string_downcasevoid string_downcase_inplaceSTRING *string_titlecasevoid string_titlecase_inplaceSTRING *string_incrementconst char *Parrot_string_cstringINTVAL Parrot_string_is_cclasss at given offset is in the given character class flags. See also include/parrot/cclass.h for possible character classes. Returns 0 otherwise, or if the string is empty or NULL.INTVAL Parrot_string_find_cclassINTVAL Parrot_string_find_not_cclassSTRING *Parrot_string_trans_charsetdest == NULL, converts src to the given charset or encoding inplace, else returns a copy of src with the charset/encoding in dest.STRING *Parrot_string_trans_encodingdest == NULL, converts src to the given charset or encoding inplace, else returns a copy of src with the charset/encoding in dest.STRING *string_composeSTRING *string_joinPMC *string_splitSTRING *uint_to_strnum converted to a Parrot STRING.base must be defined, a default of 10 is not assumed. The caller has to verify that base >= 2 && base <= 36 The buffer tc must be at least sizeof (UHUGEINTVAL)*8 + 1 chars big.minus is true then - is prepended to the string representation.STRING *int_to_strnum converted to a Parrot STRING.base must be defined, a default of 10 is not assumed.num < 0 then - is prepended to the string representation.
|  |   |