Go to the first, previous, next, last section, table of contents.


write-to-string, prin1-to-string, princ-to-string [Function]

write-to-string object {&key \writekeys{}}
=> string

prin 1 => -to-string {object} {string}

princ-to-string object => string

Arguments and Values::

object---an object.

\writekeydescriptions{}

string---a string.

Description::

write-to-string, prin1-to-string, and princ-to-string are used to create a string consisting of the printed representation of object. Object is effectively printed as if by write, prin1, or princ, respectively, and the characters that would be output are made into a string.

write-to-string is the general output function. It has the ability to specify all the parameters applicable to the printing of object.

prin1-to-string acts like write-to-string with :escape t, that is, escape characters are written where appropriate.

princ-to-string acts like write-to-string with

:escape nil :readably nil.

Thus no escape characters are written.

All other keywords that would be specified to write-to-string are default values when prin1-to-string or princ-to-string is invoked.

The meanings and defaults for the keyword arguments to write-to-string are the same as those for write.

Examples::

 (prin1-to-string "abc") =>  "\"abc\""
 (princ-to-string "abc") =>  "abc"

Affected By::

*print-escape*, *print-radix*, *print-base*, *print-circle*, *print-pretty*, *print-level*, *print-length*, *print-case*, *print-gensym*, *print-array*, *read-default-float-format*.

See Also::

@xref{write; prin1; print; pprint; princ}

Notes::

 (write-to-string object {key argument}{*})
== (with-output-to-string (#1=#:string-stream) 
     (write object :stream #1# {key argument}{*}))

 (princ-to-string object)
== (with-output-to-string (string-stream)
     (princ object string-stream))

 (prin1-to-string object)
== (with-output-to-string (string-stream)
     (prin1 object string-stream))


Go to the first, previous, next, last section, table of contents.