ascii

The ascii filter take single argument. If its argument is a string filter representing a string of a single character, then the value of the ascii filter is the ASCII value of that character.

If its argument is a numeric filter, then the value of the ascii filter is the one-character string containing the character whose ASCII value is the argument.

The ascii filter matches the current position if its argument matches and is valid: a string argument must have exactly one character; a numeric argument must lie between 1 and 255 inclusive.

(Note: We are abusing notation here by calling values between 128 and 255 "ASCII". In fact, true ASCII value must be below 128.).

The ascii filter has lower precedence than +, which makes it work intuitively with +:

    ascii "A"  65
    ascii "a"  97
    ascii 65  "A"
    ascii \"  34
    ascii 34  \"
    ascii 65 + 2  "C"
    ascii 65 + "C"  "AC"
ascii "zug" // fails to match

Example

To convert a single upper case character C to lower case, use
    ascii ascii C - ascii "A" + ascii "a"

This is parsed as

    ascii ((ascii C) - (ascii "A") + (ascii "a"))

Similarly, to convert a single lower case character C to upper case, use

    ascii ascii C - ascii "a" + ascii "A"