Previous: , Up: asciis   [Index]


1.10.4 Character predicates related to RFC 3986, Uniform Resource Identifiers

The following bindings are exported by the library (vicare language-extensions ascii-chars). The identifiers whose name is prefixed with ‘$’ are bound to unsafe operations: they do not validate the arguments and applying them to invalid arguments leads to undefined behaviour.

Syntax: $ascii-uri-reserved? fx

Evaluate to true if fx is a fixnum representing a reserved character in ASCII encoding according to RFC 3986.

Syntax: $ascii-uri-unreserved? fx

Evaluate to true if fx is a fixnum representing an unreserved character in ASCII encoding according to RFC 3986.

Syntax: $ascii-uri-gen-delim? fx

Evaluate to true if fx is a fixnum representing a gen-delim character in ASCII encoding according to RFC 3986.

Syntax: $ascii-uri-sub-delim? fx

Evaluate to true if fx is a fixnum representing a sub-delim character in ASCII encoding according to RFC 3986.

Syntax: $ascii-uri-pct-encoded? ?chi ?bv ?i

The argument ?chi must be a fixnum representing the octet at index ?i in the bytevector ?bv; ?bv and ?i must be identifiers. Return #t if the 3 bytes at offset ?i represent a percent–encoded sequence and increment ?i to reference the third octet; otherwise return #f and set ?i to the offset of the offending octet; if there are not enough octets: return #f and leave ?i unchanged.

#!vicare
(import (vicare)
  (vicare language-extensions ascii-chars))

(let* ((bv  '#ve(ascii "ciao"))
       (i   0)
       (chi (bytevector-u8-ref bv i))
       (R   ($ascii-uri-pct-encoded? chi bv i)))
  (values R i))
⇒ #f 0

(let* ((bv  '#ve(ascii "c%ABo"))
       (i   1)
       (chi (bytevector-u8-ref bv i))
       (R   ($ascii-uri-pct-encoded? chi bv i)))
  (values R i))
⇒ #t 3

(let* ((bv  '#ve(ascii "c%AB"))
       (i   1)
       (chi (bytevector-u8-ref bv i))
       (R    ($ascii-uri-pct-encoded? chi bv i)))
  (values R i))
⇒ #t 3

(let* ((bv  '#ve(ascii "c%AZ"))
       (i   1)
       (chi (bytevector-u8-ref bv i))
       (R   ($ascii-uri-pct-encoded? chi bv i)))
  (values R i))
⇒ #f 3

(let* ((bv  '#ve(ascii "c%ZA"))
       (i   1)
       (chi (bytevector-u8-ref bv i))
       (R   ($ascii-uri-pct-encoded? chi bv i)))
  (values R i))
⇒ #f 2

(let* ((bv  '#ve(ascii "c%A"))
       (i   1)
       (chi (bytevector-u8-ref bv i))
       (R   ($ascii-uri-pct-encoded? chi bv i)))
  (values R i))
⇒ #f 1
Syntax: $ascii-uri-pchar-not-percent-encoded? fx

Evaluate to true if fx is a fixnum matching the pchar component in ASCII encoding, with the exception of the percent–encoded sequence as defined by RFC 3986.

Syntax: $ascii-uri-pchar? ?chi ?bv ?i

The argument ?chi must be a fixnum representing the octet at index ?i in the bytevector ?bv; ?bv and ?i must be identifiers. Return #t if the octet ?chi or the 3 bytes at offset ?i represent pchar component in ASCII encoding; if successful increment ?i to reference the last matching octet; otherwise return #f and set ?i to the offset of the offending octet; if there are not enough octets: return #f and leave ?i unchanged.


Previous: , Up: asciis   [Index]