* Re: converting lower case to upper case
@ 1995-04-04 0:00 tmoran
1995-04-06 0:00 ` Robert Dewar
0 siblings, 1 reply; 4+ messages in thread
From: tmoran @ 1995-04-04 0:00 UTC (permalink / raw)
Ada 95 has a T_Upper function, but Ada 83 doesn't (though your
compiler vendor may provide one). If you need to roll your own:
function To_Upper(Item : in Character) return Character is
Raise_It:constant array('a' .. 'z') of Character
:="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
begin
if Item in Raise_It'range then return Raise_It(Item);
else return Item;
end if;
end To_Upper;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: converting lower case to upper case
1995-04-04 0:00 converting lower case to upper case tmoran
@ 1995-04-06 0:00 ` Robert Dewar
0 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1995-04-06 0:00 UTC (permalink / raw)
tmoran says:
"function To_Upper(Item : in Character) return Character is
Raise_It:constant array('a' .. 'z') of Character
:="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
begin
if Item in Raise_It'range then return Raise_It(Item);
else return Item;
end if;
end To_Upper;"
this is wrong, it handles only the lower part of the Ada character set,
and not Latin-1 extended characters. It is really quite important in
Ada 95 to abandon this familiar do-it-yourself-its-so-easy idiom for
case convesion, and use the routines in Ada.Characters.Handling. This
little bit of effort will be well paid off in future reuse of your code
in internatational contexts.
^ permalink raw reply [flat|nested] 4+ messages in thread
* converting lower case to upper case
@ 1995-04-01 0:00 Greg Schmitt
1995-04-02 0:00 ` Chris O'Regan
0 siblings, 1 reply; 4+ messages in thread
From: Greg Schmitt @ 1995-04-01 0:00 UTC (permalink / raw)
Hi all. I am doing an ada project and I need to convert lower
case character to a upper case character. Is there a simple way
to do this such as:
.
.
.
inch : character;
begin
if inch>='a' and inch<='z' then
inch:=toupper(inch);
end if;
end proc;
I am using a compiler on a VAX4000 I believe that it follows the 83 standards.
Thank you.
Greg Schmitt
gschmitt@cs.mtech.edu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: converting lower case to upper case
1995-04-01 0:00 Greg Schmitt
@ 1995-04-02 0:00 ` Chris O'Regan
0 siblings, 0 replies; 4+ messages in thread
From: Chris O'Regan @ 1995-04-02 0:00 UTC (permalink / raw)
In article <3llhpu$18v@nyx10.cs.du.edu>
GS := Greg Schmitt <gschmitt@nyx10.cs.du.edu>
GS>Hi all. I am doing an ada project and I need to convert lower
GS>case character to a upper case character. Is there a simple way
GS>to do this such as:
You can easily create your own To_Upper function like this:
function To_Upper (Cin : Character) return Character is
I : Integer;
Cout : Character;
begin
I := Character'Pos ('a') - Character'Pos ('Z');
if Cin in 'a'..'z' then
Cout := Character'Val (Character'Pos (Cin) - I);
else
Cout := Cin;
end if;
return Cout;
end;
I believe that the character set is standard, so you could redeclare "I"
as:
I : constant Integer := 32;
Chris O'Regan
--
______________________________________________________________________
Chris O'Regan Computer Engineering
ct_orega@ECE.Concordia.CA Concordia University
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1995-04-06 0:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-04-04 0:00 converting lower case to upper case tmoran
1995-04-06 0:00 ` Robert Dewar
-- strict thread matches above, loose matches on Subject: below --
1995-04-01 0:00 Greg Schmitt
1995-04-02 0:00 ` Chris O'Regan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox