From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: How to do case conversion?
Date: 1996/08/11
Date: 1996-08-11T00:00:00+00:00 [thread overview]
Message-ID: <dewar.839797415@schonberg> (raw)
In-Reply-To: 01bb87b9$4194f040$138371a5@dhoossr.iquest.com
David Hoos points out that Ada.Characters.Handling contains ready made
routines that use the maps in Ada.Strings.Maps.Constants, and yes, you
may as well use them if they fit. The coding is quite trivial:
function To_Lower (Item : in Character) return Character is
begin
return Value (Lower_Case_Map, Item);
end To_Lower;
function To_Lower (Item : in String) return String is
Result : String (1 .. Item'Length);
begin
for J in Item'Range loop
Result (J - (Item'First - 1)) := Value (Lower_Case_Map, Item (J));
end loop;
return Result;
end To_Lower;
It is Lower_Case_Map that is the difficult part! Note that in Ada 95 days
it is better if you can to always use this map rather than the old
add/subtract 32 ASCII trick, since that way your code work fine for
all Latin-1 letters without any extra effort on your part, and indeed
in an implementation with localizations of these packages for other
Latin sets, your code will still work.
next prev parent reply other threads:[~1996-08-11 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-08-10 0:00 How to do case conversion? Mike Shen
1996-08-11 0:00 ` David C. Hoos, Sr.
1996-08-11 0:00 ` Robert Dewar [this message]
1996-08-11 0:00 ` Robert Dewar
1996-08-12 0:00 ` Robert A Duff
1996-08-13 0:00 ` Jon S Anthony
1996-08-13 0:00 ` Robert I. Eachus
1996-08-13 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox