YAP 7.1.0
Character Encoding and Manipulation.

The Prolog library includes a set of built-in predicates designed to support manipulation of sequences of text, represented either as lists, atoms or strings. More...

Detailed Description

The Prolog library includes a set of built-in predicates designed to support manipulation of sequences of text, represented either as lists, atoms or strings.

The char_type family of predicates support manipulation of individual characters, represented either as numbers (codes) or atoms (chars)

YAP supports UNICODE through the library utf8proc for compatibility across operating systems The implementation extends the original (ASCII-based) character classification used by early Prologs, but supports UNICODE.As usual, YAP tried to follow SWI-Prolog as much as possible:

Predicates are:


Class Documentation

◆ char_type/2

class char_type/2

char_type(?_Char_ , ?Type)

The character Char has type Type The types included here are based on SWI-Prolog's documentation, and they include several types from the C-library It it is possible for a character to have different types

  • alnum Char is a letter (upper- or lowercase) or digit

+alpha Char is a letter (upper- or lowercase)

  • csym Char is a letter (upper- or lowercase), digit or the underscore (_) These are valid C and Prolog symbol characters
  • csymf Char is a letter (upper- or lowercase) or the underscore (_) These are valid first characters for C and Prolog symbols
  • ascii Char is a 7-bit ASCII character (0..127)
  • white Char is a space or tab, i.e white space inside a line
  • cntrl Char is an ASCII control character (0..31)
  • digit Char is a digit
  • digit(Weight) Char is a digit with value Weight I.e char_type(X, digit(6) yields X = '6' Useful for parsing numbers

xdigit(Weight) Char is a hexadecimal digit with value Weight I.e char_type(a, xdigit(X) yields X = '10' Useful for parsing numbers

  • graph Char produces a visible mark on a page when printed Note that the space is not included!
  • lower Char is a lowercase letter
  • lower(Upper) Char is a lowercase version of Upper Only true if Char is lowercase and Upper uppercase
  • to_lower(Upper) Char is a lowercase version of Upper For non-letters, or letter without case, Char and Lower are the same See also upcase_atom/2 and downcase_atom/2
  • upper Char is an uppercase letter
  • upper(Lower) Char is an uppercase version of Lower Only true if Char is uppercase and Lower lowercase
  • to_upper(Lower) Char is an uppercase version of Lower For non-letters, or letter without case, Char and Lower are the same See also upcase_atom/2 and downcase_atom/2
  • punct Char is a punctuation character This is a graph character that is not a letter or digit
  • space Char is some form of layout character (tab, vertical tab, newline, etc.)
  • end_of_file Char is -1
  • end_of_line Char ends a line (ASCII: 10..13)
  • newline Char is a newline character (10)
  • period Char counts as the end of a sentence (.,!,?)
  • quote Char is a quote character (", ', `)
  • paren(Close) Char is an open parenthesis and Close is the corresponding close parenthesis
  • prolog_var_start Char can start a Prolog variable name
  • prolog_atom_start Char can start a unquoted Prolog atom that is not a symbol
  • prolog_identifier_continue Char can continue a Prolog variable name or atom
  • prolog_prolog_symbol Char is a Prolog symbol character Sequences of Prolog symbol characters glue together to form an unquoted atom Examples are =.., =, etc