On this page
Ada.Characters.Conversions
Characters and strings converted between Character, Wide_Character and Wide_Wide_Character (RM A.3.4).
Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.
Availability and ownership
All of RM A.3.4. Every function is an expression function, so a proof sees exactly what it computes; narrowing gives Substitute where the narrower type lacks the code point, and string results are indexed from 1.
A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.
Import and instantiate
with Ada.Characters.Conversions;import Ada.Characters.Conversions;
A Vibe module imports this unit's names with from Ada.Characters.Conversions import Name; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.
Contract and lifecycle reading
A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.
API 001
Is_Character (declaration) — Whether a Wide_Character's code point is below 256, so that Character holds it.
Declared interface:
function Is_Character (Item : Wide_Character) return Boolean is (Wide_Character'Pos (Item) <= 255);API 002
Is_String (declaration) — Whether every character of a Wide_String is a Character (Is_Character).
Declared interface:
function Is_String (Item : Wide_String) return Boolean is
(for all I in Item'Range => Is_Character (Item (I)));API 003
Is_Character (declaration) — Whether a Wide_Wide_Character's code point is below 256.
Declared interface:
function Is_Character (Item : Wide_Wide_Character) return Boolean is (Wide_Wide_Character'Pos (Item) <= 255);API 004
Is_String (declaration) — Whether every character of a Wide_Wide_String is a Character.
Declared interface:
function Is_String (Item : Wide_Wide_String) return Boolean is
(for all I in Item'Range => Is_Character (Item (I)));API 005
Is_Wide_Character (declaration) — Whether a Wide_Wide_Character's code point is below 65536, so that Wide_Character holds it.
Declared interface:
function Is_Wide_Character (Item : Wide_Wide_Character) return Boolean is (Wide_Wide_Character'Pos (Item) <= 65535);API 006
Is_Wide_String (declaration) — Whether every character of a Wide_Wide_String is a Wide_Character.
Declared interface:
function Is_Wide_String (Item : Wide_Wide_String) return Boolean is
(for all I in Item'Range => Is_Wide_Character (Item (I)));API 007
To_Wide_Character (declaration) — The Wide_Character of the same code point: every Character is one.
Declared interface:
function To_Wide_Character (Item : Character) return Wide_Character is (Wide_Character'Val (Character'Pos (Item)));API 008
To_Wide_String (declaration) — The Wide_String of the same code points, indexed from 1.
Declared interface:
function To_Wide_String (Item : String) return Wide_String is
(Wide_String'(for I in 1 .. Item'Length => Wide_Character'Val (Character'Pos (Item (I - 1 + Item'First)))))
with Post => To_Wide_String'Result'First = 1 and then To_Wide_String'Result'Length = Item'Length;API 009
To_Wide_Wide_Character (declaration) — The Wide_Wide_Character of the same code point.
Declared interface:
function To_Wide_Wide_Character (Item : Character) return Wide_Wide_Character is (Wide_Wide_Character'Val (Character'Pos (Item)));API 010
To_Wide_Wide_String (declaration) — The Wide_Wide_String of the same code points, indexed from 1.
Declared interface:
function To_Wide_Wide_String (Item : String) return Wide_Wide_String is
(Wide_Wide_String'(for I in 1 .. Item'Length => Wide_Wide_Character'Val (Character'Pos (Item (I - 1 + Item'First)))))
with Post => To_Wide_Wide_String'Result'First = 1 and then To_Wide_Wide_String'Result'Length = Item'Length;API 011
To_Wide_Wide_Character (declaration) — The Wide_Wide_Character of a Wide_Character's code point.
Declared interface:
function To_Wide_Wide_Character (Item : Wide_Character) return Wide_Wide_Character is (Wide_Wide_Character'Val (Wide_Character'Pos (Item)));API 012
To_Wide_Wide_String (declaration) — The Wide_Wide_String of a Wide_String's code points, indexed from 1.
Declared interface:
function To_Wide_Wide_String (Item : Wide_String) return Wide_Wide_String is
(Wide_Wide_String'(for I in 1 .. Item'Length => Wide_Wide_Character'Val (Wide_Character'Pos (Item (I - 1 + Item'First)))))
with Post => To_Wide_Wide_String'Result'First = 1 and then To_Wide_Wide_String'Result'Length = Item'Length;API 013
To_Character (declaration) — The Character of the same code point, or Substitute where the code point is 256 or above.
Declared interface:
function To_Character (Item : Wide_Character; Substitute : Character := ' ') return Character is
(if Wide_Character'Pos (Item) <= 255 then Character'Val (Wide_Character'Pos (Item)) else Substitute);API 014
To_String (declaration) — Each character narrowed by To_Character with Substitute, indexed from 1.
Declared interface:
function To_String (Item : Wide_String; Substitute : Character := ' ') return String is
(String'(for I in 1 .. Item'Length => To_Character (Item (I - 1 + Item'First), Substitute)))
with Post => To_String'Result'First = 1 and then To_String'Result'Length = Item'Length;API 015
To_Character (declaration) — The Character of a Wide_Wide_Character's code point, or Substitute.
Declared interface:
function To_Character (Item : Wide_Wide_Character; Substitute : Character := ' ') return Character is
(if Wide_Wide_Character'Pos (Item) <= 255 then Character'Val (Wide_Wide_Character'Pos (Item)) else Substitute);API 016
To_String (declaration) — Each Wide_Wide_Character narrowed by To_Character with Substitute, indexed from 1.
Declared interface:
function To_String (Item : Wide_Wide_String; Substitute : Character := ' ') return String is
(String'(for I in 1 .. Item'Length => To_Character (Item (I - 1 + Item'First), Substitute)))
with Post => To_String'Result'First = 1 and then To_String'Result'Length = Item'Length;API 017
To_Wide_Character (declaration) — The Wide_Character of the same code point, or Substitute where it is 65536 or above.
Declared interface:
function To_Wide_Character (Item : Wide_Wide_Character; Substitute : Wide_Character := ' ') return Wide_Character is
(if Wide_Wide_Character'Pos (Item) <= 65535 then Wide_Character'Val (Wide_Wide_Character'Pos (Item)) else Substitute);API 018
To_Wide_String (declaration) — Each character narrowed by To_Wide_Character with Substitute, indexed from 1.
Declared interface:
function To_Wide_String (Item : Wide_Wide_String; Substitute : Wide_Character := ' ') return Wide_String is
(Wide_String'(for I in 1 .. Item'Length => To_Wide_Character (Item (I - 1 + Item'First), Substitute)))
with Post => To_Wide_String'Result'First = 1 and then To_Wide_String'Result'Length = Item'Length;