Пример #1
0
int main () {
        string s="你好";
        wstring ws=L"你好";

        cout<<s<<endl;
        cout<<wstringtostring(ws)<<endl;
        cout<<narrow(ws)<<endl;

	wcout.imbue(locale(locale(), "", LC_CTYPE));
	// wcout.imbue(locale(""));
        // wcout.imbue(locale_platform);
        wcout<<ws<<endl;
        wcout<<stringtowstring(s)<<endl;
        wcout<<widen(s)<<endl;

        wofstream fout("fout.txt");
        fout.imbue(locale_platform);
        fout<<ws<<endl;
        fout<<stringtowstring(s)<<endl;
        fout<<widen(s)<<endl;

	
//        string in;
//	copy(utf8in(s.begin()), utf8in(s.end()), back_inserter(in));
//	cout<<in<<endl;
	// copy(utf8in(s.begin()), utf8in(s.end()), back_inserter(wvect));
	// cout<<string(utf8in(s.begin()), utf8in(s.end()))<<endl;
}
Пример #2
0
const wchar_t *LDLError::getTypeNameW(LDLErrorType type)
{
	initTypeMap();
	LDLErrorTypeMap::const_iterator it = sm_typeMap.find(type);

	if (it != sm_typeMap.end())
	{
		std::wstring wkey;

		stringtowstring(wkey, it->second);
#ifdef NO_WSTRING
		return L"";
#else // NO_WSTRING
		return TCLocalStrings::get(wkey.c_str());
#endif // NO_WSTRING
	}
	else
	{
		return TCLocalStrings::get(L"LDLEUnknown");
	}
}
Пример #3
0
int LDExporter::runInternal(LDExporter *pExporter)
{
	int retValue;

	if (pExporter != NULL)
	{
		std::string filename = getFilename();

		if (filename.size() > 0)
		{
			LDLMainModel *pMainModel = new LDLMainModel;

			if (pMainModel->load(filename.c_str()))
			{
				char *cameraGlobe = stringForKey("CameraGlobe", NULL, false);
				LDLCamera camera;
				LDLAutoCamera *pAutoCamera = new LDLAutoCamera;

				pMainModel->getBoundingBox(pExporter->m_boundingMin,
					pExporter->m_boundingMax);
				pExporter->m_center = (pExporter->m_boundingMin +
					pExporter->m_boundingMax) / 2.0f;
				pExporter->m_radius =
					pMainModel->getMaxRadius(pExporter->m_center, true);
				pAutoCamera->setModel(pMainModel);
				pAutoCamera->setModelCenter(pExporter->m_center);
				pAutoCamera->setRotationMatrix(m_rotationMatrix);
				pAutoCamera->setCamera(camera);
				pAutoCamera->setCameraGlobe(cameraGlobe);
				//pAutoCamera->setDistanceMultiplier(distanceMultiplier);
				// Width and height are only needed for aspect ratio, not
				// absolute size.
				pAutoCamera->setWidth(m_width);
				pAutoCamera->setHeight(m_height);
				pAutoCamera->setFov(m_fov);
				pAutoCamera->setScanConditionalControlPoints(false);

				pAutoCamera->zoomToFit();
				pExporter->m_camera = pAutoCamera->getCamera();
				pAutoCamera->release();
				retValue = pExporter->doExport(pMainModel);
			}
			else
			{
#ifdef TC_NO_UNICODE
				consolePrintf(ls(_UC("ErrorLoadingModel")), filename.c_str());
#else // TC_NO_UNICODE
				std::wstring wfilename;
				stringtowstring(wfilename, filename);
				consolePrintf(ls(_UC("LDXErrorLoadingModel")), wfilename.c_str());
#endif // TC_NO_UNICODE
				retValue = 1;
			}
			TCObject::release(pMainModel);
		}
		else
		{
			consolePrintf(ls(_UC("LDXNoFilename")));
			retValue = 1;
		}
	}
	else
	{
		consolePrintf(ls(_UC("LDXUnknownOutputType")));
		retValue = 1;
	}
	return retValue;
}