Important: The information in this document is obsolete and should not be used for new development.
CharacterByteType
TheCharacterByteType
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 totextOffset
.SPECIAL CONSIDERATIONS
If you specifysmCurrentScript
for thescript
parameter, the value returned byCharacterByteType
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 -1 First byte of a 2-byte character smSingleByte 0 1-byte character smLastByte 1 Second byte of 2-byte character