Exemplo n.º 1
0
static const wxUint16* GetEncTable(wxFontEncoding enc)
{
#ifdef __WXMAC__
    if( enc >= wxFONTENCODING_MACMIN && enc <= wxFONTENCODING_MACMAX )
    {
        int i = enc-wxFONTENCODING_MACMIN ;
        if ( gMacEncodingsInited[i] == false )
        {
            TECObjectRef converter ;
            TextEncodingBase code = wxMacGetSystemEncFromFontEnc( enc ) ;
            TextEncodingBase unicode = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode16BitFormat) ;
            OSStatus status = TECCreateConverter(&converter,code,unicode);
            char s[2] ;
            s[1] = 0 ;
            ByteCount byteInLen, byteOutLen ;
            for( unsigned char c = 255 ; c >= 128 ; --c )
            {
                s[0] = c ;
                status = TECConvertText(converter, (ConstTextPtr) &s , 1, &byteInLen,
                (TextPtr) &gMacEncodings[i][c-128] , 2, &byteOutLen);
            }
            status = TECDisposeConverter(converter);
            gMacEncodingsInited[i]=true;
        }
        return gMacEncodings[i] ;
    }
#endif

    for (int i = 0; encodings_list[i].table != NULL; i++)
    {
        if (encodings_list[i].encoding == enc)
            return encodings_list[i].table;
    }
    return NULL;
}
XMLTranscoder*
MacOSUnicodeConverter::makeNewXMLTranscoder(const   XMLCh* const		encodingName
                                        ,       XMLTransService::Codes& resValue
                                        , const XMLSize_t               blockSize
										,		TextEncoding            textEncoding
                                        ,       MemoryManager* const    manager)
{
    XMLTranscoder* result = NULL;
	resValue = XMLTransService::Ok;
    OSStatus status = noErr;
    
    TECObjectRef textToUnicode = NULL;
    TECObjectRef unicodeToText = NULL;
    
    //  We convert to and from utf16
    TextEncoding utf16Encoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
                                        kTextEncodingDefaultVariant,
                                        kUnicode16BitFormat);

    //  Create a TEC from our encoding to utf16
    if (status == noErr)
        status = TECCreateConverter(&textToUnicode, textEncoding, utf16Encoding);

    //  Create a TEC from utf16 to our encoding
    if (status == noErr)
        status = TECCreateConverter(&unicodeToText, utf16Encoding, textEncoding);

	if (status != noErr)
	{
        //  Clean up on error
		if (textToUnicode != NULL)
            TECDisposeConverter(textToUnicode);
			
		if (unicodeToText != NULL)
            TECDisposeConverter(unicodeToText);

		resValue = XMLTransService::UnsupportedEncoding;
	}
	else
    {
        //  Create our transcoder, passing in the converters
		result = new (manager) MacOSTranscoder(encodingName, textToUnicode, unicodeToText, blockSize, manager);
    }
	
    return result;
}
Exemplo n.º 3
0
void TextCodecMac::releaseTECConverter() const
{
    if (m_converterTEC) {
        if (cachedConverterTEC != 0)
            TECDisposeConverter(cachedConverterTEC);
        cachedConverterTEC = m_converterTEC;
        cachedConverterEncoding = m_encoding;
        m_converterTEC = 0;
    }
}
Exemplo n.º 4
0
void TextCodecMac::releaseTECConverter() const
{
    if (m_converterTEC) {
        TECConverterWrapper& cachedConverter = cachedConverterTEC();
        if (cachedConverter.converter)
            TECDisposeConverter(cachedConverter.converter);
        cachedConverter.converter = m_converterTEC;
        cachedConverter.encoding = m_encoding;
        m_converterTEC = 0;
    }
}
Exemplo n.º 5
0
void
shoes_world_free(shoes_world_t *world)
{
#ifdef SHOES_QUARTZ
  CFRelease(world->os.clip);
  TECDisposeConverter(world->os.converter);
#endif
  rb_gc_unregister_address(&world->apps);
  rb_gc_unregister_address(&world->msgs);
  if (world != NULL)
    SHOE_FREE(world);
}
MacOSTranscoder::~MacOSTranscoder()
{
	//	Dispose our text encoding converters
	TECDisposeConverter(mTextToUnicode);
	TECDisposeConverter(mUnicodeToText);
}