Legacy Documentclose button

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

Up Previous Next 

PATH 
Mac OS 8 and 9 Developer Documentation > Text Encoding Conversion Manager
Programming With the Text Encoding Conversion Manager



ConvertFromPStringToUnicode

Converts a Pascal string in a Mac OS text encoding to a Unicode string.

pascal OSStatus ConvertFromPStringToUnicode (
                     TextToUnicodeInfo iTextToUnicodeInfo,
                     ConstStr255Param iPascalStr,
                     ByteCount iOutputBufLen,
                     ByteCount *oUnicodeLen,
                     UniCharArrayPtr oUnicodeStr);
iTextToUnicodeInfo
A Unicode converter object of type TextToUnicodeInfo for the Pascal string to be converted. You can use the function CreateTextToUnicodeInfo or CreateTextToUnicodeInfoByEncoding to create the Unicode converter object.

iPascalStr
The Pascal string to be converted to Unicode.

iOutputBufLen
The length in bytes of the output buffer pointed to by the oUnicodeStr parameter. Your application supplies this buffer to hold the returned converted string. The oUnicodeLen parameter may return a byte count that is less than this value if the converted string is smaller than the buffer size you allocated.

oUnicodeLen
A pointer to a value of type ByteCount. On output, the length in bytes of the converted Unicode string returned in the oUnicodeStr parameter.

oUnicodeStr
A pointer to a Unicode character array. On output, this buffer holds the converted Unicode string. For information on the Unicode character array, see Unicode Character and String Pointer Data Types .

function result
A result code. The function returns the noErr result code if it has completely converted the Pascal string to Unicode without using fallback characters. If the function returns the paramErr, kTECTableFormatErr, or kTECGlobalsUnavailableErr result codes, it did not convert the string.

If the function returns kTECBufferBelowMinimumSizeErr, the output buffer was too small to allow conversion of any part of the input string. You need to increase the size of the output buffer and try again.

If the function returns the kTECUsedFallbacksStatus result code, the function has completely converted the Pascal string using one or more fallback characters.

If the function returns kTECOutputBufferFullErr, the output buffer was not big enough to completely convert the input. You can call the function again with another output buffer--or with the same output buffer, after copying its contents--to convert the remainder of the input string.

If the function returns kTECPartialCharErr, the input buffer ended with an incomplete multibyte character. If you have subsequent input text available, you can append the unconverted input from this call to the beginning of the subsequent input text and call the function again.

See Text Encoding Conversion Manager Result Codes in the chapter Basic Text Types Reference for other possible values.

DISCUSSION

The ConvertFromPStringToUnicode function provides an easy and efficient way to convert a short Pascal string to a Unicode string without incurring the overhead associated with the function ConvertFromTextToUnicode.

If necessary, this function automatically uses fallback characters to map the text elements of the string.


© 1999 Apple Computer, Inc. – (Last Updated 13 Dec 99)

Up Previous Next