cdef extern from "include_CoreServices.h": # This is how you get an encoding ctypedef enum DontCareScriptParameters: kTextScriptDontCare = -128 kTextLanguageDontCare = -128 kTextRegionDontCare = -128 ctypedef enum UsefulErrors: kTECBufferBelowMinimumSizeErr = -8750 kTECArrayFullErr = -8751 kTECPartialCharErr = -8753 kTECUnmappableElementErr = -8754 kTECIncompleteElementErr = -8755 kTECUsedFallbacksStatus = -8783 kTECOutputBufferFullStatus = -8785 ctypedef enum ConversionMasks: kUnicodeUseFallbacksMask = 1 << 0 kUnicodeKeepInfoMask = 1 << 1 kUnicodeLooseMappingsMask = 1 << 4 kUnicodeStringUnterminatedMask = 1 << 6 ctypedef enum FallbackPreference: kUnicodeFallbackDefaultOnly = 0 kUnicodeFallbackCustomOnly = 1 kUnicodeFallbackDefaultFirst = 2 kUnicodeFallbackCustomFirst = 3 cdef OSErr UpgradeScriptInfoToTextEncoding(int iTextScriptID, int iTextLanguageID, int iRegionID, Str255 iTextFontName, int* oEncoding) # These are Text -> Unicode functions ctypedef void* TextToUnicodeInfo cdef OSErr CreateTextToUnicodeInfoByEncoding(int iEncoding, TextToUnicodeInfo* oTextToUnicodeInfo) cdef OSErr ConvertFromTextToUnicode( TextToUnicodeInfo iTextToUnicodeInfo, int iSourceLen, void *iSourceStr, int iControlFlags, int iOffsetCount, int *iOffsetArray, int *oOffsetCount, int *oOffsetArray, int iOutputBufLen, int *oSourceRead, int *oUnicodeLen, UniChar *oUnicodeStr) cdef OSErr DisposeTextToUnicodeInfo(TextToUnicodeInfo *ioTextToUnicodeInfo) cdef OSErr ResetTextToUnicodeInfo(TextToUnicodeInfo ioTextToUnicodeInfo) # These are Unicode -> Text functions ctypedef void* UnicodeToTextInfo cdef OSErr CreateUnicodeToTextInfoByEncoding(int iEncoding, UnicodeToTextInfo* oUnicodeToTextInfo) cdef OSErr ConvertFromUnicodeToText( UnicodeToTextInfo iUnicodeToTextInfo, int iUnicodeLen, void *iUnicodeStr, int iControlFlags, int iOffsetCount, int *iOffsetArray, int *oOffsetCount, int *oOffsetArray, int iOutputBufLen, int *oInputRead, int *oOutputLen, char *oOutputStr) cdef OSErr DisposeUnicodeToTextInfo(UnicodeToTextInfo *ioUnicodeToTextInfo) cdef OSErr ResetUnicodeToTextInfo(UnicodeToTextInfo ioUnicodeToTextInfo) ctypedef OSStatus (*UnicodeToTextFallbackProcPtr)( UniChar *iSrcUniStr, int iSrcUniStrLen, int *oSrcConvLen, char *oDestStr, int iDestStrLen, int *oDestConvLen, int iInfoPtr, void *iUnicodeMappingPtr)