• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
        • Pretty-printing
        • Printtree
        • Base64
        • Charset-p
        • Strtok!
        • Cases
        • Concatenation
        • Html-encoding
        • Character-kinds
        • Substrings
        • Strtok
        • Equivalences
        • Url-encoding
          • *url-encode-array*
          • Url-encode-chars-aux
          • Url-encode-char
          • Url-encode-chars
          • Url-encode-string
          • Url-encode-string-aux
            • Fast-url-encode-char
          • Lines
          • Ordering
          • Numbers
          • Pad-trim
          • Coercion
          • Std/strings-extensions
          • Std/strings/digit-to-char
          • Substitution
          • Symbols
        • Std/io
        • Std/osets
        • Std/system
        • Std/basic
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
        • Std-extensions
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Url-encoding

    Url-encode-string-aux

    Efficiently way to URL encode a string, in reverse order, without exploding it.

    Signature
    (url-encode-string-aux x n xl acc) → *
    Arguments
    x — Guard (stringp x).
    n — Guard (natp n).
    xl — Guard (eql xl (length x)).

    This has such a nice logical definition that we just leave it enabled.

    Definitions and Theorems

    Function: url-encode-string-aux

    (defun
     url-encode-string-aux (x n xl acc)
     (declare (xargs :guard (and (stringp x)
                                 (natp n)
                                 (eql xl (length x)))))
     (declare (xargs :guard (<= n xl)))
     (let ((acl2::__function__ 'url-encode-string-aux))
          (declare (ignorable acl2::__function__))
          (mbe :logic (url-encode-chars-aux (nthcdr n (explode x))
                                            acc)
               :exec (b* (((when (mbe :logic (zp (- (nfix xl) (nfix n)))
                                      :exec (eql n xl)))
                           acc)
                          (char (char x n))
                          (encoding (fast-url-encode-char char))
                          (acc (revappend encoding acc)))
                         (url-encode-string-aux x (+ 1 (lnfix n))
                                                xl acc)))))