Next: , Previous: Unicode, Up: Unicode


5.7.1 Wide Strings

Wide characters can be combined into wide strings, which are similar to strings but can contain any Unicode character sequence. The implementation used for wide strings is guaranteed to provide constant-time access to each character in the string.

— procedure: wide-string? object

Returns #t if object is a wide string.

— procedure: make-wide-string k [wide-char]

Returns a newly allocated wide string of length k. If char is specified, all elements of the returned string are initialized to char; otherwise the contents of the string are unspecified.

— procedure: wide-string wide-char ...

Returns a newly allocated wide string consisting of the specified characters.

— procedure: wide-string-length wide-string

Returns the length of wide-string as an exact non-negative integer.

— procedure: wide-string-ref wide-string k

Returns character k of wide-string. K must be a valid index of string.

— procedure: wide-string-set! wide-string k wide-char

Stores char in element k of wide-string and returns an unspecified value. K must be a valid index of wide-string.

— procedure: string->wide-string string [start [end]]

Returns a newly allocated wide string with the same contents as string. If start and end are supplied, they specify a substring of string that is to be converted. Start defaults to ‘0’, and end defaults to ‘(string-length string)’.

— procedure: wide-string->string wide-string [start [end]]

Returns a newly allocated string with the same contents as wide-string. The argument wide-string must satisfy wide-string?. If start and end are supplied, they specify a substring of wide-string that is to be converted. Start defaults to ‘0’, and end defaults to ‘(wide-string-length wide-string)’.

It is an error if any character in wide-string fails to satisfy char-ascii?.

— procedure: open-wide-input-string wide-string [start [end]]

Returns a new input port that sources the characters of wide-string. The optional arguments start and end may be used to specify that the port delivers characters from a substring of wide-string; if not given, start defaults to ‘0’ and end defaults to ‘(wide-string-length wide-string)’.

— procedure: open-wide-output-string

Returns an output port that accepts wide characters and strings and accumulates them in a buffer. Call get-output-string on the returned port to get a wide string containing the accumulated characters.

— procedure: call-with-wide-output-string procedure

Creates a wide-string output port and calls procedure on that port. The value returned by procedure is ignored, and the accumulated output is returned as a wide string. This is equivalent to:

          (define (call-with-wide-output-string procedure)
            (let ((port (open-wide-output-string)))
              (procedure port)
              (get-output-string port)))