Next: , Previous: , Up: Strings and Characters   [Contents][Index]

4.4 Modifying Strings

You can alter the contents of a mutable string via operations described in this section. See Mutability.

The most basic way to alter the contents of an existing string is with aset (see Functions that Operate on Arrays). (aset string idx char) stores char into string at character index idx. It will automatically convert a pure-ASCII string to a multibyte string (see Text Representations) if needed, but we recommend to always make sure string is multibyte (e.g., by using string-to-multibyte, see Converting Text Representations), if char is a non-ASCII character, not a raw byte.

To clear out a string that contained a password, use clear-string:

Function: clear-string string

This makes string a unibyte string and clears its contents to null characters. It may also change string’s length.