Coverage report: /home/ellis/.stash/quicklisp/dists/ultralisp/software/edicl-flexi-streams-20240429143708/strings.lisp
Kind | Covered | All | % |
expression | 11 | 53 | 20.8 |
branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*-
2
;;; $Header: /usr/local/cvsrep/flexi-streams/strings.lisp,v 1.34 2008/05/26 10:55:08 edi Exp $
4
;;; Copyright (c) 2005-2008, Dr. Edmund Weitz. All rights reserved.
6
;;; Redistribution and use in source and binary forms, with or without
7
;;; modification, are permitted provided that the following conditions
10
;;; * Redistributions of source code must retain the above copyright
11
;;; notice, this list of conditions and the following disclaimer.
13
;;; * Redistributions in binary form must reproduce the above
14
;;; copyright notice, this list of conditions and the following
15
;;; disclaimer in the documentation and/or other materials
16
;;; provided with the distribution.
18
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
19
;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22
;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24
;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
(in-package :flexi-streams)
32
(defun string-to-octets (string &key
33
(external-format :latin1)
34
(start 0) (end (length string)))
35
"Converts the Lisp string STRING from START to END to an array of
36
octets corresponding to the external format designated by
39
In spite of the name, STRING can be any sequence of characters, but
40
the function is optimized for strings."
41
(declare #.*standard-optimize-settings*)
42
(setq external-format (maybe-convert-external-format external-format))
43
;; the external format knows how to do it...
44
(string-to-octets* external-format string start end))
46
(defun octets-to-string (sequence &key
47
(external-format :latin1)
48
(start 0) (end (length sequence)))
49
"Converts the Lisp sequence SEQUENCE of octets from START to END to
50
a string using the external format designated by EXTERNAL-FORMAT.
52
This function is optimized for the case of SEQUENCE being a vector.
53
Don't use lists if you're in a hurry."
54
(declare #.*standard-optimize-settings*)
55
(declare (fixnum start end))
56
(setq external-format (maybe-convert-external-format external-format))
57
;; the external format knows how to do it...
58
(octets-to-string* external-format sequence start end))
60
(defun octet-length (string &key (external-format :latin1) (start 0) (end (length string)))
61
"Returns the length of the substring of STRING from START to END in
62
octets if encoded using the external format EXTERNAL-FORMAT.
64
In spite of the name, STRING can be any sequence of characters, but
65
the function is optimized for strings."
66
(declare #.*standard-optimize-settings*)
67
(declare (fixnum start end))
68
(setq external-format (maybe-convert-external-format external-format))
69
(compute-number-of-octets external-format string start end))
71
(defun char-length (sequence &key (external-format :latin1) (start 0) (end (length sequence)))
72
"Kind of the inverse of OCTET-LENGTH. Returns the length of the
73
subsequence \(of octets) of SEQUENCE from START to END in characters
74
if decoded using the external format EXTERNAL-FORMAT. Note that this
75
function doesn't check for the validity of the data in SEQUENCE.
77
This function is optimized for the case of SEQUENCE being a vector.
78
Don't use lists if you're in a hurry."
79
(declare #.*standard-optimize-settings*)
80
(declare (fixnum start end))
81
(setq external-format (maybe-convert-external-format external-format))
82
(compute-number-of-chars external-format sequence start end))