// ---------------------------------------------------------------------------
//  MacOSTransService: The protected virtual transcoding service API
// ---------------------------------------------------------------------------
XMLTranscoder*
MacOSUnicodeConverter::makeNewXMLTranscoder(const   XMLCh* const		encodingName
                                        ,       XMLTransService::Codes& resValue
                                        , const XMLSize_t               blockSize
                                        ,       MemoryManager* const    manager)
{
	XMLTranscoder* result = NULL;
	resValue = XMLTransService::Ok;
	
	TextToUnicodeInfo textToUnicodeInfo = NULL;
	UnicodeToTextInfo unicodeToTextInfo = NULL;

	//	Map the encoding to a Mac OS Encoding value
	Str255 pasEncodingName;
	char cEncodingName[256];
	ConvertWideToNarrow(encodingName, cEncodingName, sizeof(cEncodingName));
	CopyCStringToPascal(cEncodingName, pasEncodingName);
	
	TextEncoding textEncoding = 0;
	OSStatus status = TECGetTextEncodingFromInternetName (
							&textEncoding,
							pasEncodingName);
                            
    //  Make a transcoder for that encoding
	if (status == noErr)
		result = makeNewXMLTranscoder(encodingName, resValue, blockSize, textEncoding, manager);
	else
		resValue = XMLTransService::UnsupportedEncoding;
	
	return result;
}
Esempio n. 2
0
void CConsoleWindow::CopyToClipboard() const
	{
    if (OpenClipboard(Handle())) 
		{
	    EmptyClipboard();
		LPTSTR wideSelection = iView->Selection();
		if (wideSelection)
			{
			int length = wcslen(wideSelection);
			HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (length + 1) * sizeof(TCHAR));
			if (hglbCopy)
				{
				char* narrowBuf = (char*)GlobalLock(hglbCopy);
				ConvertWideToNarrow(wideSelection, length, narrowBuf);
				GlobalUnlock(hglbCopy);
				SetClipboardData(CF_TEXT, hglbCopy);
				iView->ClearSelection();
				}
			delete wideSelection;
			}
		CloseClipboard();
		}
	}