string-utils

  1. string-utils
  2. Documentation
    1. Memoized String
      1. Usage
      2. make-string*
    2. String Hexadecimal
      1. Usage
      2. string->hex
    3. Unicode Utilities
      1. Usage
      2. ascii-codepoint?
      3. unicode-char->string
      4. unicode-string
      5. unicode-make-string
      6. unicode-surrogate?
      7. unicode-surrogates->codepoint
    4. String Utilities
  3. Usage
    1. Bytes to Hexadecimal
      1. Usage
      2. str_to_hex
      3. blob_to_hex
      4. u8vec_to_hex
      5. s8vec_to_hex
      6. mem_to_hex
  4. Requirements
  5. Author
  6. Version history
  7. License

Documentation

Memoized String

Usage

(require-extension memoized-string)

make-string*

[procedure] (make-string* COUNT [FILL]) => string

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 Hexadecimal

Usage

(require-extension string-hexadecimal)

string->hex

[procedure] (string->hex STRING [START [END]]) => string

Returns a hexadecimal represenation of STRING. START and END are substring limits.

STRING is treated as a string of bytes, a byte-vector.

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

(require-extension unicode-utils)

ascii-codepoint?

[procedure] (ascii-codepoint? CHAR) => boolean

unicode-char->string

[procedure] (unicode-char->string CHAR) => string

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

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-make-string

[procedure] (unicode-make-string COUNT [FILL]) => string

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

unicode-surrogates->codepoint

[procedure] (unicode-surrogates->codepoint HIGH LOW) => (union boolean fixnum)

Returns the codepoint for the valid surrogate pair HIGH and LOW. Otherwise returns #f.

String Utilities

Reexports all of the above.

Usage

(require-extension string-utils)

Bytes to Hexadecimal

A common bytevector-like object to hexadecimal string facility.

No error checking is performed!

Usage

(require-extension to-hex)

str_to_hex

[procedure] (str_to_hex OUT IN OFF LEN)

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)

Like str_to_hex except IN is a nonnull-blob.

u8vec_to_hex

[procedure] (u8vec_to_hex OUT IN OFF LEN)

Like str_to_hex except IN is a nonnull-u8vector.

s8vec_to_hex

[procedure] (s8vec_to_hex OUT IN OFF LEN)

Like str_to_hex except IN is a nonnull-s8vector.

mem_to_hex

[procedure] (mem_to_hex OUT IN OFF LEN)

Like str_to_hex except IN is a nonnull-c-pointer.

Requirements

check-errors lookup-table

Author

Kon Lovett

Version history

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-2012 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.