Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg]] == string-utils [[toc:]] == Documentation === Memoized String ==== Usage <enscript language=scheme> (import memoized-string) </enscript> ==== make-string+ <procedure>(make-string+ COUNT [FILL]) -> string</procedure> An ''interning'' {{make-string}}. {{FILL}} is any valid {{char}}, including codepoints outside of the ASCII range, which produce UTF-8 strings. ==== string+ <procedure>(string+ [CHAR...]) -> string</procedure> An ''interning'' {{string}}. {{CHAR}} is any valid {{char}}, including codepoints outside of the ASCII range, which produce UTF-8 strings. ==== global-string <procedure>(global-string STR) -> string</procedure> Share common string space. === String Hexadecimal ==== Usage <enscript language=scheme> (import string-hexadecimal) </enscript> ==== string->hex <procedure>(string->hex STRING [START [END]]) -> string</procedure> Returns a hexadecimal {{string}} (Latin1) from {{STRING}} (Latin1). {{START}} and {{END}} are substring limits. {{STRING}} is treated as a string of bytes. ==== hex->string <procedure>(hex->string STRING [START [END]]) -> string</procedure> Returns the {{string}} (Latin1) from a hexadecimal {{STRING}} (Latin1). {{START}} and {{END}} are substring limits. ==== utf8->hex <procedure>(utf8->hex STRING [START [END]]) -> string</procedure> Returns a hexadecimal {{string}} (Latin1) from {{STRING}} (Utf8). {{START}} and {{END}} are substring limits. {{STRING}} is treated as a string of bytes. ==== hex->utf8 <procedure>(hex->string STRING [START [END]]) -> string</procedure> Returns the {{string}} (Utf8) from a hexadecimal {{STRING}} (Latin1). {{START}} and {{END}} are substring limits. === String Utilities ==== Usage <enscript language=scheme> (import string-utils) </enscript> ==== string-split-chars <procedure>(string-split-chars STR [DELIMITERS]) -> (list-of string) (list-of char)</procedure> Returns a {{list}} of substrings of STR & a {{list}} of the characters, from DELIMITERS, separating those substrings. ; STR : {{string}} ; version string. ; DELIMITERS : {{string}} ; string of version component delimiter characters, default {{".,"}}. <enscript language=scheme> (string-split-chars "a.2,c" "$,.") ;=> ("a" "2" "c") (#\. #\,) </enscript> ==== string-unzip <procedure>(string-unzip STR [DELIMITERS]) -> (list-of string) (list-of string)</procedure> Returns a {{list}} of substrings of STR & a {{list}} of the delimiters, from DELIMITERS, separating those substrings. ; STR : {{string}} ; version string. ; DELIMITERS : {{string}} ; string of version component delimiter characters, default {{".,"}}. <enscript language=scheme> (string-unzip "a.2,c" "$,.") ;=> ("a" "2" "c") ("." ",") </enscript> ==== string-zip <procedure>(string-zip PARTS PUNCS) -> string</procedure> Returns a {{string}} formed from the concatenation of the PARTS and the interspersion of the PUNCS. ; PARTS : {{(list-of string)}} ; version components. ; PUNCS : {{(list-of string)}} ; version component separators. <enscript language=scheme> (string-zip ("a" "2" "c") ("." ",")) ;=> "a.2,c" </enscript> ==== string-trim-whitespace-both <procedure>(string-trim-whitespace-both S) -> string</procedure> Returns the {{string}} {{S}} with whitespace trimmed. ==== list-as-string <procedure>(list-as-string LS) -> string</procedure> Returns the {{list}} {{LS}} written to a {{string}}. ==== number->padded-string <procedure>(number->padded-string N WIDTH [PADCHAR [BASE]]) -> string</procedure> ; N : {{number}} ; source ; WIDTH : {{fixnum}} ; field width ; PADCHAR : {{char}} ; padding character ; BASE : {{fixnum}} ; number conversion base ==== string-fixed-length <procedure>(string-fixed-length S N [pad-char: #\space] [trailing: "..."]) -> string</procedure> Returns the {{string}} {{S}} with the {{string-length}} fixed to {{N}}. A shorter string is padded. A longer string is truncated, & suffixed with the {{trailing}}. ==== string-subsequence? <procedure>(string-subsequence? S T) -> boolean</procedure> Returns whether the characters of {{S}} occur in order thru {{T}}. ==== string-longest-common-prefix <procedure>(string-longest-common-prefix STRINGS) -> string</procedure> Returns the longest comment prefix of {{STRINGS}}. ; STRINGS : {{(list-of string)}} ==== string-longest-common-suffix <procedure>(string-longest-common-suffix STRINGS) -> string</procedure> Returns the longest comment suffix of {{STRINGS}}. ; STRINGS : {{(list-of string)}} ==== string-longest-prefix <procedure>(string-longest-prefix CANDIDATE OTHERS) -> (or boolean string)</procedure> Returns the member with the longest comment prefix of {{CANDIDATE}} from {{OTHERS}}, or {{#f}}. ; CANDIDATE : {{string}} ; OTHERS : {{(list-of string)}} ==== string-longest-suffix <procedure>(string-longest-suffix CANDIDATE OTHERS) -> (or boolean string)</procedure> Returns the member with the longest comment suffix of {{CANDIDATE}} from {{OTHERS}}, or {{#f}}. ; CANDIDATE : {{string}} ; OTHERS : {{(list-of string)}} === String Interpolation Extends the read-syntax with #"..." where tagged scheme expressions in the string are evaluated at runtime: <enscript> #"@ #(+ 1 2)## (#'and #1 #2) = #(and 1 2) trailing #" ;=> "@ 3# (and 1 2) = 2 trailing #" </enscript> Similar to the {{#<#}} multi-line string. See [[http://wiki.call-cc.org/man/5/Extensions%20to%20the%20standard#multiline-string-constant-with-embedded-expressions|Multiline String Constant with Embedded Expressions]]. '''Note''' Support for the #{<sexpr>} subform is dropped. So {{SRFI 105}} can work as expected: <enscript> (import (srfi-105 extra)) #"1 + 3 = #{1 + 3}" ;=> "1 + 3 = 4" #"An \"#{string-append(\"Hello, \" \"World\")}\" example" ;=> "An \"Hello, World\" example" </enscript> ==== Usage <enscript language=scheme> (import string-interpolation) </enscript> ==== Compiler Command-Line <enscript> csc -extend string-interpolation ... </enscript> ==== Interpreter Command-Line <enscript> csi -require-extension string-interpolation ... </enscript> Activates string-interpolation {{#"..."}} syntax. === String Interpolation Syntax ==== Usage <enscript language=scheme> (import string-interpolation-syntax) </enscript> ==== set-sharp-string-interpolation-syntax <procedure>(set-sharp-string-interpolation-syntax PROC)</procedure> Extends the read-syntax with #"..." where the {{"..."}} is evaluated using {{(PROC "...")}}. ; {{PROC}} : {{#f}} ; read-syntax is cleared. ; {{PROC}} : {{#t}} ; {{PROC}} is {{identity}}. ; {{PROC}} : {{procedure}} ; interpolation function. === String Interpolator ==== Usage <enscript language=scheme> (import string-interpolator) </enscript> ==== string-interpolate <procedure>(string-interpolate STR [eval-tag: EVAL-TAG]) -> list</procedure> Performs substitution of embedded Scheme expressions, prefixed with {{EVAL-TAG}}. Two consecutive {{EVAL-TAG}}s are translated to a single {{EVAL-TAG}}. A trailing {{EVAL-TAG}} is taken literally. ; {{STR}} : {{string}}. ; {{EVAL-TAG}} : {{character}}, default {{#\#}}. === String Wrap ==== Usage <enscript language=scheme> (import string-wrap) </enscript> ==== line-break <procedure>(line-break STR WID) -> (list-of string)</procedure> Returns the wrapped substrings from the text {{STR}}, each less-than or equal to the line width {{WID}}. Breaks the line at a {{#\space}}. === Rabin Karp String Search ==== Usage <enscript language=scheme> (import rabin-karp) </enscript> ==== make-string-search <procedure>(make-string-search STRINGS [COMPARE [HASH]]) -> SEARCHER</procedure> ; {{STRINGS}} : {{(list-of string)}} ; ; {{COMPARE}} : {{(string string --> boolean)}} ; ; {{HASH}} : {{(string [BOUNDS []])}} ; {{SRFI-69}} hash procedure. ; {{SEARCHER}} : {{(string [START [END]]) --> RESULT}} ; {{RESULT}} : {{(or #f (STRING . (START . END)))}} ; success or failure result ==== collect-string-search <procedure>(collect-string-search SEARCHER TARGET) -> (list-of RESULT)</procedure> Perform exhaustive search of the {{TARGET}}, returing a list of {{RESULT}}. ; {{SEARCHER}} : from {{make-string-search}} ; {{TARGET}} : {{string}} ; search within ; {{RESULT}} : {{(or #f (STRING . (START . END)))}} ; success or failure result === Hexadecimal Procedures ==== Usage <enscript language=scheme> (import to-hex) </enscript> {{OUT}} is a {{bytevector}} of length >= {{(+ LEN 2)}}. {{OFF}} is the byte offset. {{LEN}} is the length of the bytes at {{OFF}}. ==== str_to_hex <procedure>(str_to_hex OUT IN OFF LEN) -> string</procedure> Writes the hexadecimal {{string}} (Latin1) of {{IN}} to {{OUT}}. {{IN}} is a {{nonnull-string}} (Latin1). ==== utf8_to_hex <procedure>(utf8_to_hex OUT IN OFF LEN) -> string</procedure> {{IN}} is a {{nonnull-string}} (Utf8). ==== bv_to_hex <procedure>(bv_to_hex OUT IN OFF LEN) -> string</procedure> {{IN}} is a {{nonnull-blob}}. ==== u8vec_to_hex <procedure>(u8vec_to_hex OUT IN OFF LEN) -> string</procedure> {{IN}} is a {{nonnull-u8vector}}. ==== s8vec_to_hex <procedure>(s8vec_to_hex OUT IN OFF LEN) -> string</procedure> {{IN}} is a {{nonnull-s8vector}}. ==== mem_to_hex <procedure>(mem_to_hex OUT IN OFF LEN) -> string</procedure> {{IN}} is a {{nonnull-c-pointer}}. ==== hex_to_str <procedure>(hex_to_str OUT IN OFF LEN) -> string</procedure> Parses the hexadecimal {{string}} (Latin1) of {{IN}} as a {{string}} (Latin1). ==== hex_to_utf8 <procedure>(hex_to_utf8 OUT IN OFF LEN) -> string</procedure> Parses the hexadecimal {{string}} (Latin1) of {{IN}} as a {{string}} (Utf8). ==== hex_to_bv <procedure>(hex_to_bv OUT IN OFF LEN) -> bytevector</procedure> Parses the hexadecimal {{string}} (Latin1) of {{IN}} as a {{bytevector}}. == Requirements [[srfi-1]] [[srfi-13]] [[srfi-14]] [[srfi-69]] [[check-errors]] [[miscmacros]] [[test]] [[test-utils]] == Author [[/users/kon-lovett|Kon Lovett]] == Version history ; 3.1.0 : Add {{string-wrap}}. ; 3.0.0 : C6 release. == License Copyright (C) 2010-2025 Kon Lovett. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICESLOSS OF USE, DATA, OR PROFITSOR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 12 to 11?