Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Text /
Chapter 6 - Script Manager / Script Manager Reference
Routines / Analyzing Characters


CharacterByteType

The CharacterByteType function identifies a byte in a text buffer as a 1-byte character or as the first or second byte of a 2-byte character.

FUNCTION CharacterByteType (textBuf: Ptr; textOffset: Integer; 
                            script: ScriptCode): Integer;
textBuf
A pointer to a text buffer containing the byte to be identified.
textOffset
The offset to the byte to be identified. Offset is measured in bytes; the first byte has an offset of 0.
script
A value that specifies the script system of the text in the buffer. Constants for all defined script codes are listed on page 6-52. To specify the font script, pass smCurrentScript in this parameter.
DESCRIPTION
CharacterByteType returns one of three identifications: a 1-byte character, the first byte of a 2-byte character, or the second byte of a 2-byte character. The first byte of a 2-byte character--the one at the lower offset in memory--is the high-order byte; the second byte of a 2-byte character--the one at the higher offset--is the low-order byte. This is the same order in which text is processed and numbers are represented.

From byte value alone, it is not possible to distinguish the second byte of a 2-byte character from a 1-byte character. See the discussion of character encoding in the chapter "Introduction to Text on the Macintosh" in this book. CharacterByteType differentiates the second byte of a 2-byte character from a 1-byte character by assuming that the byte at offset 0 is the first byte of a character. With that assumption, it then sequentially identifies the size and starting position of each character in the buffer up to textOffset.

SPECIAL CONSIDERATIONS
If you specify smCurrentScript for the script parameter, the value returned by CharacterByteType can be affected by the state of the font force flag. It is unaffected by the state of the international resources selection flag.

RESULT CODES
smFirstByte-1First byte of a 2-byte character
smSingleByte 01-byte character
smLastByte 1Second byte of 2-byte character

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996