International Text (IText)
This section describes the utilities defined in the files IText.h and IText.cpp. These utilities create, destroy, and manipulate international text (ODIText) structures, which contain a variable-size text buffer as well as Mac OS script and language codes.Creation in Default Heap
The following functions create anODITextstructure using a C string. On the Mac OS, theODScriptCodeand theODLangCodeparameters correspond to the platform script code and language code. TheCreateITextfunction is overloaded to use different types of input parameters, as shown throughout this section.
ODIText* CreateITextCString(ODScriptCode script, ODLangCode lang, char* text); ODIText* CreateIText(ODScriptCode script, ODLangCode lang, char* text);The following functions create anODITextstructure using a Pascal string:
ODIText* CreateITextPString(ODScriptCode script, ODLangCode lang, StringPtr text); ODIText* CreateIText(ODScriptCode script, ODLangCode lang, StringPtr text);The following functions create anODITextstructure with an empty string of specified length:
ODIText* CreateITextClear(ODScriptCode script, ODLangCode lang, ODSize stringLength ); ODIText* CreateIText(ODScriptCode script, ODLangCode lang, ODSize stringLength );The following functions create anODITextstructure with a buffer of characters of specified length:
ODIText* CreateITextWLen(ODScriptCode script, ODLangCode lang, ODUByte* text, ODSize textLength ); ODIText* CreateIText(ODScriptCode script, ODLangCode lang, ODUByte* text, ODSize textLength)The following function sets the buffer size of theODITextstructure. If the inputODITextpointer iskODNULL, this function is equivalent to theCreateITextClearfunction.
ODIText* SetITextBufferSize(ODIText* text, ODSize bufferSize, ODBoolean preserveContents );Destruction
The following function disposes of anODITextstructure and any memory associated with it:
void DisposeIText(ODIText* text);The following function is the same as theDisposeITextfunction except that it works onODITextstructure allocated on the stack:
void DisposeITextStruct(ODIText text);Duplication
The following function allocates and returns an exact copy of theODITextstructure passed in:
ODIText* CopyIText(ODIText* original);The following function is the same as theCopyITextfunction except that the returnedODITextstructure is allocated on the stack:
ODIText CopyITextStruct(ODIText* original);Accessing Attributes
The following functions set and get the script code of theODITextstructure passed in:
void SetITextScriptCode(ODIText* text, ODScriptCode script); ODScriptCode GetITextScriptCode(ODIText* text);The following functions set and get the language code of theODITextstructure passed in:
void SetITextLangCode(ODIText* text, ODLangCode lang); ODLangCode GetITextLangCode(ODIText* text);The following function sets the length of theODITextstructure's string length field. IfkODNULLis passed in as the inputODIText, the function is equivalent to theCreateITextClearfunction.
ODIText* SetITextStringLength( ODIText* text, ODSize length, ODBoolean preserveText); ODIText* CreateIText(ODSize length);The following function returns the string length of theODITextstructure passed in:
ODULong GetITextStringLength(ODIText* text);Accessing the String
The following function returns a pointer to the raw text without allocating any memory.
- IMPORTANT
- This function should be used with extreme caution because the pointer returned belongs to the
ODITextstructure.
char* GetITextPtr(ODIText* text);The following functions set the string of theODITextstructure with a C string. Note that theSetITextStringfunction is overloaded and can also take a Pascal string:
void SetITextCString(ODIText* iText, char* cString); void SetITextString(ODIText* iText, char* cString); The following functions set the string of the ODIText structure with a Pascal string. void SetITextPString(ODIText* iText, StringPtr pString); void SetITextString(ODIText* iText, StringPtr pString); The following function sets the string of the ODIText structure with a buffer of the specified length: void SetITextText(ODIText* text, ODUByte* text, ODSize textLength);The following functions return to a C string a pointer that corresponds to the string in theODITextstructure. If a string is passed in, the same string is used to return the result. Otherwise, this function allocates memory for the returned string. Note that theGetITextStringfunction is overloaded and can also take and return a Pascal string.
char* GetITextCString(ODIText* iText, char* cString); char* GetITextString(ODIText* iText, char* cString); char* GetCStringFromIText(ODIText* iText);The following functions work like theGetITextCStringfunction except that they return a Pascal string:
StringPtr GetITextPString(ODIText*, Str255 pString); StringPtr GetITextString(ODIText* i, StringPtr pString); StringPtr GetPStringFromIText(ODIText* iText);
Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help