[comp.sys.mac.programmer] upper2lower

ollef@sics.se (Olle Furberg) (02/17/91)

  What's the right way to convert a letter from upper to lower case?
For all letters A-Z, it's very easy. But how do I find the lower case
version of "E" with acute accent?

  There's another problem with letters like "E" with trema, which only exists
in some fonts (e.g. Times), how do I know if the current font hasn't put
something else in the last 40 positions?


     /Olle

resnick@cogsci.uiuc.edu (Pete Resnick) (02/18/91)

ollef@sics.se (Olle Furberg) writes:

>  What's the right way to convert a letter from upper to lower case?
>For all letters A-Z, it's very easy. But how do I find the lower case
>version of "E" with acute accent?

>  There's another problem with letters like "E" with trema, which only exists
>in some fonts (e.g. Times), how do I know if the current font hasn't put
>something else in the last 40 positions?

In the Script Manager 2.0 docs, there are two routines declared:

Pascal:

Procedure UprText(textPtr: Ptr; len: Integer);
Procedure LwrText(textPtr: Ptr; len: Integer);

C:

pascal void UprText(Ptr textPtr, short len);
pascal void LwrText(Ptr textPtr, short len);

Each takes text up to 32K in length. For more compicated conversions, there
is the Transliterate function, documented in IM V-311.
--
Pete Resnick             (...so what is a mojo, and why would one be rising?)
Graduate assistant - Philosophy Department, Gregory Hall, UIUC
System manager - Cognitive Science Group, Beckman Institute, UIUC
Internet/ARPAnet/EDUnet  : resnick@cogsci.uiuc.edu
BITNET (if no other way) : FREE0285@UIUCVMD

ftanaka@Apple.COM (Forrest Tanaka) (02/18/91)

ollef@sics.se (Olle Furberg) writes:

>  What's the right way to convert a letter from upper to lower case?
>For all letters A-Z, it's very easy. But how do I find the lower case
>version of "E" with acute accent?

One way to convert a run of text between upper case and lower case is to use
the Transliterate routine, documented on pages 311 and 312 of Inside Macintosh
V.  Starting from system software version 6.0.4, it uses the extended Macintosh
character set that all the LaserWriter fonts (Times, Helvetica, etc.) have for
Roman text. The character mapping for the extended Macintosh character set
define that characters with certain diacriticals must be at the locations that
you can see in the LaserWriter fonts, so if you use a font that doesn't use
that character mapping, you could get funny results.  This routine, as with
many other Script Manager routines, checks on the type face of the current
GrafPort to determine how to do the conversion.  So it uses the extended
Macintosh character set mapping if the current GrafPort's type face is Roman,
and it uses a different character mapping if the current type face is
Cyrillic, for example.

Transliterate is a pretty hefty routine, so if you don't want to put up with
its bulk, you can convert strings from upper case to lower case using the
simpler and faster routine LowerText.  It's documented in the Worldwide
Software Overview chapter of Inside Macintosh VI, and it's documented as
LwrText and LwrString in the Script Manager 2.0 documentation.  Starting from
system software version 6.0.4, LowerText became localizable because it uses
information in the current font script's itl2 to do the conversion.

To convert lower case text to upper case, you have to use Transliterate.  But
with system software version 7.0, you can use the UpperText routine which
uses the current font script's itl2 to do the conversion.  There was an
UprText routine that also did the conversion, but it used hard-coded tables
and was not localizable, and I think it used the traditional Macintosh
character set instead of the extended one.
-- 
Forrest Tanaka
Graphics/Toolbox Developer Technical Support
Apple Computer, Inc.
AppleLink: TANAKA
Internet: ftanaka@apple.com