Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/string-utils|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. [[tags: egg]] == string-utils [[toc:]] == Documentation === Memoized String ==== Usage <enscript language=scheme> (require-extension memoized-string) </enscript> ==== make-string+ <procedure>(make-string+ COUNT [FILL]) -> string</procedure> A ''tabling'' {{make-string}}. {{FILL}} is any valid {{char}}, including codepoints outside of the ASCII range. As such UTF-8 strings can be memoized. ==== string+ <procedure>(string+ [CHAR...]) -> string</procedure> A ''tabling'' {{string}}. {{CHAR}} is any valid {{char}}, including codepoints outside of the ASCII range. As such UTF-8 strings can be memoized. ==== global-string <procedure>(global-string STR) -> string</procedure> Share common string space. ==== make-string* (DEPRECATED) <procedure>(make-string* COUNT [FILL]) -> string</procedure> === String Hexadecimal ==== Usage <enscript language=scheme> (require-extension string-hexadecimal) </enscript> ==== string->hex <procedure>(string->hex STRING [START [END]]) -> string</procedure> Returns a hexadecimal represenation of {{STRING}}. {{START}} and {{END}} are substring limits. {{STRING}} is treated as a string of bytes, a byte-vector. ==== hex->string <procedure>(hex->string STRING [START [END]]) -> string</procedure> Returns the binary representation of a hexadecimal{{STRING}}. {{START}} and {{END}} are substring limits. === Unicode Utilities The name of this extension is misleading. Only UTF-8 is currently supported. For a better treatment of UTF-8 see the [[utf-8]] extension. ==== Usage <enscript language=scheme> (require-extension unicode-utils) </enscript> ==== ascii-codepoint? <procedure>(ascii-codepoint? CHAR) -> boolean</procedure> ==== unicode-char->string <procedure>(unicode-char->string CHAR) -> string</procedure> Returns a string formed from Unicode codepoint {{CHAR}}. ''Note'' that the {{(string-length)}} (except under [[utf-8]]) may not be equal to {{1}}. Generates an error should the codepoint be out-of-range. ==== unicode-string <procedure>(unicode-string [CHAR...]) -> string</procedure> Returns a string formed from Unicode codepoints {{CHAR...}} ''Note'' that the {{(string-length)}} (except under [[utf-8]]) may not be equal to the length of {{CHAR...}}. Generates an error should the codepoint be out-of-range. ==== *unicode-string <procedure>(*unicode-string CHARS) -> string</procedure> Returns a string formed from Unicode codepoints {{CHARS}}, a {{(list-of char)}}. ==== unicode-make-string <procedure>(unicode-make-string COUNT [FILL]) -> string</procedure> Returns a string formed from {{COUNT}} occurrences of the Unicode codepoint {{FILL}}. The {{FILL}} default is {{#\space}}. ''Note'' that the {{(string-length)}} (except under [[utf-8]]) may not be equal to {{COUNT}}. Generates an error should the codepoint be out-of-range. ==== unicode-surrogate? <procedure>(unicode-surrogate? NUM) -> boolean</procedure> ==== unicode-surrogates->codepoint <procedure>(unicode-surrogates->codepoint HIGH LOW) -> (or boolean fixnum)</procedure> Returns the codepoint for the valid surrogate pair {{HIGH}} and {{LOW}}. Otherwise returns {{#f}}. === String Extensions Some multi-string replacements. ==== Usage <enscript language=scheme> (require-extension string-utils-extensions) </enscript> ==== string-copy-over! <procedure>(string-copy-over! FROM TO [START [END]]) -> string</procedure> Copies a substring of {{FROM}}, determined by {{START}} & {{END}}. Returns the modified {{TO}}. : {{FROM}} ; {{string}} ; : {{TO}} ; {{string}} ; : {{START}} ; {{fixnum}} ; default {{0}} : {{END}} ; {{fixnum}} ; default {{string-length}} ==== string-count* <procedure>(string-count* PRED? [STR ...]) -> fixnum</procedure> : {{STR}} ; {{string}} ; : {{PRED?}} ; {{(#!rest char --> boolean)}} ; ==== string-any* <procedure>(string-any* PRED? [STR ...]) -> (or boolean char)</procedure> : {{STR}} ; {{string}} ; : {{PRED?}} ; {{(#!rest char --> boolean)}} ; ==== string-every* <procedure>(string-every* PRED? [STR ...]) -> (or boolean char)</procedure> : {{STR}} ; {{string}} ; : {{PRED?}} ; {{(#!rest char --> boolean)}} ; === String Utilities Reexports all of the above. ==== Usage <enscript language=scheme> (require-extension string-utils) </enscript> === Bytes to Hexadecimal A common bytevector-like object to hexadecimal string facility. No error checking is performed! ==== Usage <enscript language=scheme> (require-extension to-hex) </enscript> ==== str_to_hex <procedure>(str_to_hex OUT IN OFF LEN)</procedure> Writes the ASCII hexadecimal representation of {{IN}} to {{OUT}}. {{IN}} is a {{nonnull-string}}. {{OFF}} is the byte offset. {{LEN}} is the length of the bytes at {{OFF}}. {{OUT}} is a {{string}} of length >= {{(+ LEN 2)}}. ==== blob_to_hex <procedure>(blob_to_hex OUT IN OFF LEN)</procedure> Like {{str_to_hex}} except {{IN}} is a {{nonnull-blob}}. ==== u8vec_to_hex <procedure>(u8vec_to_hex OUT IN OFF LEN)</procedure> Like {{str_to_hex}} except {{IN}} is a {{nonnull-u8vector}}. ==== s8vec_to_hex <procedure>(s8vec_to_hex OUT IN OFF LEN)</procedure> Like {{str_to_hex}} except {{IN}} is a {{nonnull-s8vector}}. ==== mem_to_hex <procedure>(mem_to_hex OUT IN OFF LEN)</procedure> Like {{str_to_hex}} except {{IN}} is a {{nonnull-c-pointer}}. ==== hex_to_str <procedure>(hex_to_str OUT IN OFF LEN)</procedure> Reads the ASCII hexadecimal representation of {{IN}} to {{OUT}}. {{IN}} is a {{nonnull-string}}. {{OFF}} is the byte offset. {{LEN}} is the length of the bytes at {{OFF}}. {{OUT}} is a {{string}} of length >= {{(/ LEN 2)}}. ==== hex_to_str <procedure>(hex_to_blob OUT IN OFF LEN)</procedure> Like {{hex_to_str}} except {{OUT}} is a {{blob}} of size >= {{(/ LEN 2)}}. === String Interpolation ==== Usage <enscript language=scheme> (require-extension string-interpolation) </enscript> <enscript language=scheme> (require-extension utf8-string-interpolation) </enscript> ==== string-interpolate <procedure>(string-interpolate STR [eval-tag: EVAL-TAG] [eval-env: EVAL-ENV]) -> string</procedure> Performs substitution of embedded Scheme expressions, evaluated in the {{EVAL-ENV}}, prefixed with {{EVAL-TAG}} and optionally enclosed in curly brackets. Two consecutive {{EVAL-TAG}}s are translated to a single {{EVAL-TAG}}. Similar to the {{#<#}} multi-line string. {{STR}} is a {{string}}. {{EVAL-TAG}} is a {{character}}, default {{#\#}}. {{EVAL-ENV}} is an {{environment}}, default {{(interaction-environment)}}. ==== Usage <enscript language=scheme> (require-extension 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 "...")}}. When {{PROC}} is {{#f}} the read-syntax is cleared. When {{PROC}} is {{#t}} then {{PROC}} is {{identity}}. <enscript language=scheme> (use string-interpolation-syntax utf8-string-interpolation) (set-sharp-string-interpolation-syntax string-interpolate) ;#"foo #(+ 1 2)bar #{(and 1 2)} baz" ;=> "foo 3bar 2 baz" </enscript> == Requirements [[check-errors]] [[miscmacros]] [[utf8]] [[setup-helper]] [[test]] == Author [[/users/kon-lovett|Kon Lovett]] == Version history ; 1.6.0 : Add {{string-utils-extensions}}. ; 1.5.6 : Add types. ; 1.5.5 : ; 1.5.4 : ; 1.5.3 : {{memorize-string}} -> {{global-string}}. ; 1.5.2 : Fix {{string+}} & {{memorize-string}}. ; 1.5.1 : Fix {{string+}} unicode support. ; 1.5.0 : Deprecate {{make-string*}} for {{make-string+}}, add {{memorize-string}} & {{string+}}. ; 1.4.0 : Add string-interpolation modules. ; 1.3.1 : Fix {{hex_to_str}}, {{hex_to_blob}}. ; 1.3.0 : Add {{hex->string}}, {{hex_to_str}}, {{hex_to_blob}}. ; 1.2.5 : Remove [[lookup-table]]. ; 1.2.2 : Unicode string construction a little faster. Removed {{blob->hex}}. ; 1.2.1 : Added {{blob->hex}}. ; 1.2.0 : Added "generic" bytes to hexadecimal string. ; 1.1.0 : Split into separate modules. Added some UTF-8 support. ; 1.0.0 : Hello == License Copyright (C) 2010-2017 Kon Lovett. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 7 from 24?