DEVELOPMENT EDITION · 769442725406
Library Reference
On this page

Package Ada.Wide_Wide_Characters.Handling

Verada predefined library: Ada.Wide_Wide_Characters.Handling (Ada RM A.3.5) for all of Unicode (16.0.0), by the general categories and mappings of Verada.Strings.Unicode. Each classification and character conversion is an expression function, so that proofs see what it computes: of Latin-1 characters exactly, of the others through the run time's tables. The case conversions are Unicode's simple mappings (one character for one: 'ß' has no upper case here). Is_Basic and To_Basic are of letters, as Ada.Characters.Handling's are: a basic letter is one with no decomposition, and To_Basic takes a letter that is a letter and combining marks to that letter (its accents removed, all of them).

Character_Set_Version

function Character_Set_Version return String is ("Unicode 16.0.0");

the version of Unicode the classifications follow

Category

function Category (Item : Wide_Wide_Character) return Verada.Strings.Unicode.General_Category is
  (Verada.Strings.Unicode.Category (Wide_Wide_Character'Pos (Item)));

(Unicode's general category of a character)

Is_Control

function Is_Control (Item : Wide_Wide_Character) return Boolean is
  (Category (Item) = Verada.Strings.Unicode.Cc);

a control character (Cc)

Is_Letter

function Is_Letter (Item : Wide_Wide_Character) return Boolean is
  (Category (Item) in Verada.Strings.Unicode.Lu .. Verada.Strings.Unicode.Lo | Verada.Strings.Unicode.Nl);

a letter (Lu, Ll, Lt, Lm, Lo) or a letter number (Nl)

Is_Lower

function Is_Lower (Item : Wide_Wide_Character) return Boolean is
  (Category (Item) = Verada.Strings.Unicode.Ll);

a lower-case letter (Ll)

Is_Upper

function Is_Upper (Item : Wide_Wide_Character) return Boolean is
  (Category (Item) = Verada.Strings.Unicode.Lu);

an upper-case letter (Lu)

Is_Digit

function Is_Digit (Item : Wide_Wide_Character) return Boolean is
  (Category (Item) = Verada.Strings.Unicode.Nd);

a decimal digit of any script (Nd)

Is_Decimal_Digit

function Is_Decimal_Digit (Item : Wide_Wide_Character) return Boolean renames Is_Digit;

Is_Hexadecimal_Digit

function Is_Hexadecimal_Digit (Item : Wide_Wide_Character) return Boolean is
  (Is_Digit (Item) or else Item in 'A' .. 'F' | 'a' .. 'f');

Is_Alphanumeric

function Is_Alphanumeric (Item : Wide_Wide_Character) return Boolean is
  (Is_Letter (Item) or else Is_Digit (Item));

Is_Line_Terminator

function Is_Line_Terminator (Item : Wide_Wide_Character) return Boolean is
  (Category (Item) in Verada.Strings.Unicode.Zl | Verada.Strings.Unicode.Zp
   or else Wide_Wide_Character'Pos (Item) in 10 .. 13 | 16#85#);

a line separator (Zl), a paragraph separator (Zp), or one of LF, VT, FF, CR and NEL

Is_Mark

function Is_Mark (Item : Wide_Wide_Character) return Boolean is
  (Category (Item) in Verada.Strings.Unicode.Mn | Verada.Strings.Unicode.Mc);

a combining mark (Mn, Mc)

Is_Other_Format

function Is_Other_Format (Item : Wide_Wide_Character) return Boolean is
  (Category (Item) = Verada.Strings.Unicode.Cf);

a format character (Cf)

Is_Punctuation_Connector

function Is_Punctuation_Connector (Item : Wide_Wide_Character) return Boolean is
  (Category (Item) = Verada.Strings.Unicode.Pc);

a connector punctuation (Pc), such as '_'

Is_Space

function Is_Space (Item : Wide_Wide_Character) return Boolean is
  (Category (Item) = Verada.Strings.Unicode.Zs);

a space separator (Zs)

Is_NFKC

function Is_NFKC (Item : Wide_Wide_Character) return Boolean is
  (Verada.Strings.Unicode.Is_NFKC (Wide_Wide_Character'Pos (Item)));

whether Item can be in a string normalized to Unicode's form KC

Is_Graphic

function Is_Graphic (Item : Wide_Wide_Character) return Boolean is
  (Category (Item) not in Verada.Strings.Unicode.Zl | Verada.Strings.Unicode.Zp | Verada.Strings.Unicode.Cc
                        | Verada.Strings.Unicode.Cs | Verada.Strings.Unicode.Co
   and then Wide_Wide_Character'Pos (Item) mod 16#1_0000# < 16#FFFE#);

a graphic character (RM 2.1): not a control, private-use or surrogate character, not a line or paragraph separator, and not the last two positions of a plane

Is_Special

function Is_Special (Item : Wide_Wide_Character) return Boolean is
  (Is_Graphic (Item) and then not Is_Alphanumeric (Item));

To_Upper

function To_Upper (Item : Wide_Wide_Character) return Wide_Wide_Character is
  (Wide_Wide_Character'Val (Verada.Strings.Unicode.Simple_Upper (Wide_Wide_Character'Pos (Item))));

the simple upper-case mapping of Item, else Item

To_Lower

function To_Lower (Item : Wide_Wide_Character) return Wide_Wide_Character is
  (Wide_Wide_Character'Val (Verada.Strings.Unicode.Simple_Lower (Wide_Wide_Character'Pos (Item))));

the simple lower-case mapping of Item, else Item

To_Basic

function To_Basic (Item : Wide_Wide_Character) return Wide_Wide_Character is
  (Wide_Wide_Character'Val (Verada.Strings.Unicode.Basic (Wide_Wide_Character'Pos (Item))));

the basic letter of a letter with diacritical marks ('A' for 'Å' and 'Ǻ'), else Item

Is_Basic

function Is_Basic (Item : Wide_Wide_Character) return Boolean is
  (Is_Letter (Item) and then To_Basic (Item) = Item
   and then not Verada.Strings.Unicode.Has_Compatibility_Decomposition (Wide_Wide_Character'Pos (Item)));

a letter that To_Basic leaves as it is and that has no compatibility decomposition (not 'ª' nor the ligature 'fi')

To_Upper

function To_Upper (Item : Wide_Wide_String) return Wide_Wide_String
  with Global => null,
       Post => To_Upper'Result'First = 1 and then To_Upper'Result'Length = Item'Length
               and then (for all I in 1 .. Item'Length => To_Upper'Result (I) = To_Upper (Item (I - 1 + Item'First)));

To_Lower

function To_Lower (Item : Wide_Wide_String) return Wide_Wide_String
  with Global => null,
       Post => To_Lower'Result'First = 1 and then To_Lower'Result'Length = Item'Length
               and then (for all I in 1 .. Item'Length => To_Lower'Result (I) = To_Lower (Item (I - 1 + Item'First)));

To_Basic

function To_Basic (Item : Wide_Wide_String) return Wide_Wide_String
  with Global => null,
       Post => To_Basic'Result'First = 1 and then To_Basic'Result'Length = Item'Length
               and then (for all I in 1 .. Item'Length => To_Basic'Result (I) = To_Basic (Item (I - 1 + Item'First)));