Пример #1
0
static void load_encoding_name(ENCODING enc, WCHAR* buffer, int length)
{
    switch (enc)
    {
        case ENCODING_UTF16LE:
            LoadStringW(Globals.hInstance, STRING_UNICODE_LE, buffer, length);
            break;

        case ENCODING_UTF16BE:
            LoadStringW(Globals.hInstance, STRING_UNICODE_BE, buffer, length);
            break;

        case ENCODING_UTF8:
            LoadStringW(Globals.hInstance, STRING_UTF8, buffer, length);
            break;

        case ENCODING_ANSI:
        {
            CPINFOEXW cpi;
            GetCPInfoExW(CP_ACP, 0, &cpi);
            lstrcpynW(buffer, cpi.CodePageName, length);
            break;
        }

        default:
            assert(0 && "bad encoding in load_encoding_name");
            break;
    }
}
Пример #2
0
int ustring_GetCPInfo(lua_State *L)
{
	UINT codepage;
	CPINFOEXW info;
	memset(&info, 0, sizeof(info));
	codepage = (UINT)luaL_checkinteger(L, 1);

	if(!GetCPInfoExW(codepage, 0, &info))
		return SysErrorReturn(L);

	lua_createtable(L, 0, 6);
	PutNumToTable(L, "MaxCharSize",  info.MaxCharSize);
	PutLStrToTable(L, "DefaultChar", (const char*)info.DefaultChar, MAX_DEFAULTCHAR);
	PutLStrToTable(L, "LeadByte", (const char*)info.LeadByte, MAX_LEADBYTES);
	PutWStrToTable(L, "UnicodeDefaultChar", &info.UnicodeDefaultChar, 1);
	PutNumToTable(L, "CodePage",     info.CodePage);
	PutWStrToTable(L, "CodePageName", info.CodePageName, -1);
	return 1;
}
Пример #3
0
idupdater::idupdater( QObject *parent )
:	QNetworkAccessManager( parent )
,	m_autoupdate( false )
,	m_autoclose( false )
,	w(0)
{
	QLocale::Language language = QLocale::system().language();
	QString locale = language == QLocale::C ? "English/United States" : QLocale::languageToString( language );
#ifdef Q_OS_WIN
	CPINFOEX CPInfoEx = { 0 };
	if( GetCPInfoExW( GetConsoleCP(), 0, &CPInfoEx ) != 0 )
		locale += " / " + QString( (QChar*)CPInfoEx.CodePageName );
#else
	QString ctype = QProcessEnvironment::systemEnvironment().value( "LC_CTYPE" );
	locale += " / " + (!ctype.isEmpty() ? ctype : QProcessEnvironment::systemEnvironment().value( "LANG" ));
#endif

	QPCSC pcsc;
	QString userAgent = QString( "%1/%2 (%3) Locale: %4 Devices: %5")
		.arg( qApp->applicationName(), InstallChecker::installedVersion("{58A1DBA8-81A2-4D58-980B-4A6174D5B66B}"), applicationOs(), locale, pcsc.drivers().join("/") );
	qDebug() << "User-Agent:" << userAgent;
	request.setRawHeader( "User-Agent", userAgent.toUtf8() );
	connect( this, SIGNAL(finished(QNetworkReply*)), SLOT(reply(QNetworkReply*)) );
}