Next: , Previous: , Up: iklib strings   [Index]


6.27.4 Converting between strings and other objects

Function: string->utf8-length str

Given a string compute and return the length of the bytevector that would contain its UTF-8 representation. If the bytevector length would exceed the maximum length of a bytevector: return #f.

Function: string->utf16-length str

Given a string compute and return the length of the bytevector that would contain its UTF-16 representation. If the bytevector length would exceed the maximum length of a bytevector: return #f.

Function: string->utf32-length str

Given a string compute and return the length of the bytevector that would contain its UTF-32 representation. If the bytevector length would exceed the maximum length of a bytevector: return #f.

Function: string->octets string
Function: octets->string bytevector

Convert to and from a Scheme string and a Scheme bytevector holding the raw octets encoding of the characters. Octets are converted to characters with integer->char; characters are converted to octets with char->integer. Raise an exception if the conversion is not possible.

Function: string->ascii string
Function: ascii->string bytevevctor

Convert to and from a Scheme string and a Scheme bytevector holding the ASCII encoding of the characters.

Function: octets-encoded-string? string

Return #t if string can be interpreted as an octets encoded string, otherwise return #f. A character is considered an octets–encoded if its integer representation chi satisfies:

(<= 0 chi 255)      ⇒ #t
Function: ascii-encoded-string? string

Return #t if string can be interpreted as an ASCII encoded string, otherwise return #f. A character is considered an ASCII code point if its integer representation chi satisfies:

(<= #x00 chi #x7F)      ⇒ #t
Function: string->latin1 string
Function: latin1->string bytevevctor

Convert to and from a Scheme string and a Scheme bytevector holding the Latin-1 encoding of the characters.

Function: latin1-encoded-string? string

Return #t if string can be interpreted as a Latin1 encoded string, otherwise return #f. iklib chars unicode latin1 for the definition of Latin-1 encoding used by Vicare.

Function: string->utf16le string
Function: string->utf16be string
Function: string->utf16n string

Convert from a Scheme string to a Scheme bytevector holding the UTF-16 encoding of the characters under little, big or native endianness respectively.

Function: utf16le->string bytevector
Function: utf16be->string bytevector
Function: utf16n->string bytevector
Function: utf16le->string bytevector error-handling-mode
Function: utf16be->string bytevector error-handling-mode
Function: utf16n->string bytevector error-handling-mode

Convert to a Scheme string from a Scheme bytevector holding the UTF-16 encoding of characters under little, big or native endianness respectively.

The optional argument error-handling-mode has the same values and meaning it has for utf16->string.

Function: string-hex->bytevector string
Function: bytevector->string-hex bytevector

Convert to and from a Scheme string and a Scheme bytevector.

The input string contains the uppercase or lowercase hexadecimal representation of the octets. The output string contains the uppercase hexadecimal representation of octets.

If an error occurs in the conversion: the return value is #f.

Function: string-base64->bytevector string
Function: bytevector->string-base64 bytevector

Convert to and from a Scheme string and a Scheme bytevector. The input string contains the ASCII Base64 representation of the octets. The output string contains the ASCII Base64 representation of octets. If an error occurs in the conversion: an exception is raised.

Function: string->uri-encoding str
Function: string->percent-encoding str

Convert the string str to its UTF-8 representation, then encode such representation according to RFC 3986, URI percent encoding.

Function: uri-encoding->string bytevector
Function: percent-encoding->string bytevector

Interpret the bytevector as encoded according to RFC 3986, URI percent encoding, decode it and interpret the result as the UTF-8 representation of a string; return the string.

Function: uri-encoded-string? string
Function: percent-encoded-string? string

Return #t if the argument is correctly percent–encoded string according to RFC 3986. This means every character in the string is associated to a character in the ASCII encoding and additionally the constraints of RFC 3986 are satisfied.

Function: string-or-symbol->string obj

If obj is a string return a copy of it; if it is a symbol return a new string object equal to its string name.

Function: string-or-symbol->symbol obj

If obj is a symbol return it; if it is a string return a symbol having it as string name.


Next: , Previous: , Up: iklib strings   [Index]