## Strings and compilation

### C Reference

Base string constructors

Building strings for C data

#### Function

    	  cl_object ecl_alloc_adjustable_base_string
    	  cl_index length

    	  cl_object ecl_alloc_adjustable_simple_string
    	  cl_index length

    	  cl_object ecl_make_simple_base_string
    	  ecl_base_char* data
    	  cl_index length

    	  cl_object ecl_make_constant_base_string
    	  ecl_base_char* data
    	  cl_index length

##### Description

These are different ways to create a base string, which is a string that holds a small subset of characters, the `base-char`, with codes ranging from 0 to 255.

`ecl_alloc_simple_base_string` creates an empty string with that much space for characters and a fixed lenght. The string does not have a fill pointer and cannot be resized, and the initial data is unspecified

`ecl_alloc_adjustable_base_string` is similar to the previous function, but creates an adjustable string with a fill pointer. This means that the lenght of the string can be changed and the string itself can be resized to accomodate more data.

The other constructors create strings but use some preexisting data. `ecl_make_simple_base_string` creates a string copying the data that the user supplies, and using freshly allocated memory. `ecl_make_constant_base_string` on the other hand, does not allocate memory, but simply uses the supplied pointer as buffer for the string. This last function should be used with care, ensuring that the supplied buffer is not deallocated.

String accessors

Reading and writing characters into a string

#### Function

    	  ecl_character  ecl_char
    	  cl_object string
    	  cl_index ndx

    	  ecl_character  ecl_char_set
    	  cl_object string
    	  cl_index ndx
    	  ecl_character c

##### Description

Access to string information should be done using these two functions. The first one implements the equivalent of the CHAR function from Common Lisp, returning the character that is at position `ndx` in the string `s`.

The counterpart of the previous function is `ecl_char_set`, which implements (SETF CHAR) and stores character `c` at the position `ndx` in the given string.

Both functions check the type of their arguments and verify that the indices do not exceed the string boundaries. Otherwise they signal a `serious-condition`.

Strings C dictionary

&ANSI-C-Dict;

- Lisp symbol
- C function
- simple-string-p
- `cl_object cl_simple_string_p(cl_object string)`
- char
- `cl_object cl_char(cl_object string, cl_object index)`
- schar
- `cl_object cl_schar(cl_object string, cl_object index)`
- string
- `cl_object cl_string(cl_object x)`
- string-upcase
- `cl_object cl_string_upcase(cl_narg narg, cl_obejct string, ...)`
- string-downcase
- `cl_object cl_string_downcase(cl_narg narg, cl_obejct string, ...)`
- string-capitalize
- `cl_object cl_string_capitalize(cl_narg narg, cl_obejct string, ...)`
- nstring-upcase
- `cl_object cl_nstring_upcase(cl_narg narg, cl_obejct string, ...)`
- nstring-downcase
- `cl_object cl_nstring_downcase(cl_narg narg, cl_obejct string, ...)`
- nstring-capitalize
- `cl_object cl_nstring_capitalize(cl_narg narg, cl_obejct string, ...)`
- string-trim
- `cl_object cl_string_trim(cl_object character_bag, cl_object string)`
- string-left-trim
- `cl_object cl_string_left_trim(cl_object character_bag, cl_object string)`
- string-right-trim
- `cl_object cl_string_right_trim(cl_object character_bag, cl_object string)`
- string
- `cl_object cl_string(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string=
- `cl_object cl_stringE(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string/=
- `cl_object cl_stringNE(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string<
- `cl_object cl_stringL(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string>
- `cl_object cl_stringG(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string<=
- `cl_object cl_stringLE(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string>=
- `cl_object cl_stringGE(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string-equal
- `cl_object cl_string_equal(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string-not-equal
- `cl_object cl_string_not_equal(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string-lessp
- `cl_object cl_string_lessp(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string-greaterp
- `cl_object cl_string_greaterp(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string-not-greaterp
- `cl_object cl_string_not_greaterp(cl_narg narg, cl_object string1, cl_object string2, ...)`
- string-not-lessp
- `cl_object cl_string_not_lessp(cl_narg narg, cl_object string1, cl_object string2, ...)`
- stringp
- `cl_object cl_stringp(cl_object x)`
- make-string
- `cl_object cl_make_string(cl_narg narg, cl_object size, ...)`