Exemplo n.º 1
0
// Returns BCP47 Language Tag
DllExport const char *
getJavaIDFromLangID(LANGID langID)
{
    char * elems[5]; // lang, script, ctry, variant, encoding
    char * ret = malloc(SNAMESIZE);
    int index;

    SetupI18nProps(MAKELCID(langID, SORT_DEFAULT),
                   &(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4]));

    // there always is the "language" tag
    strcpy(ret, elems[0]);

    // append other elements, if any
    for (index = 1; index < 4; index++) {
        if ((elems[index])[0] != '\0') {
            strcat(ret, "-");
            strcat(ret, elems[index]);
        }
    }

    for (index = 0; index < 5; index++) {
        free(elems[index]);
    }

    return ret;
}
Exemplo n.º 2
0
void FillCombo(HWND hwnd, int id, int indexSettings)
{
	HKL saved = SettingsGlobal().hkl_lay[indexSettings];
	bool found = false;
	for (int i = 0; i < g_laySize; i++)
	{
		HKL cur = g_laylist[i];
		WORD langid = LOWORD(cur);
		TCHAR buf[512]; buf[0] = 0;
		int flag = IsWindowsVistaOrGreater() ? LOCALE_SNAME : LOCALE_SLANGUAGE;
		int len = GetLocaleInfo(MAKELCID(langid, SORT_DEFAULT), flag, buf, 512);
		SW_WINBOOL_LOG(len != 0);
		SendDlgItemMessage(hwnd, id, CB_ADDSTRING, 0, (LPARAM)buf);
		if (saved == cur)
		{
			found = true;
			SendDlgItemMessage(hwnd, id, CB_SETCURSEL, (WPARAM)i, (LPARAM)0);
		}
	}
	if(!found)
	{
		SendDlgItemMessage(hwnd, id, CB_SETCURSEL, (WPARAM)0, (LPARAM)0);
	}

	

}
Exemplo n.º 3
0
CP_CONVERTER_API int GBKToGB2312(LPCSTR lpMultiByteStrSrc, int cbMultiByteSrc, LPSTR lpMultiByteStrDst, int cbMultiByteDst)
{
	DWORD dwLCID = MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), SORT_CHINESE_BIG5);
	int nResult = 0;
	nResult = ::LCMapString(dwLCID, LCMAP_SIMPLIFIED_CHINESE, lpMultiByteStrSrc, cbMultiByteSrc, lpMultiByteStrDst, cbMultiByteDst);
	return nResult;
}
Exemplo n.º 4
0
/*
 *  Get the lconv fields.
 */
static int __cdecl _get_lc_lconv (
    struct lconv *l
)
{
    int ret = 0;

    /* Currency is country--not language--dependent.  NT work-around. */
    LCID ctryid=MAKELCID(__lc_id[LC_MONETARY].wCountry, SORT_DEFAULT);

    if (l == NULL)
        return -1;

    ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SINTLSYMBOL, (void *)&l->int_curr_symbol);
    ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SCURRENCY, (void *)&l->currency_symbol);
    ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SMONDECIMALSEP, (void *)&l->mon_decimal_point);
    ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SMONTHOUSANDSEP, (void *)&l->mon_thousands_sep);
    ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SMONGROUPING, (void *)&l->mon_grouping);
    fix_grouping(l->mon_grouping);

    ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SPOSITIVESIGN, (void *)&l->positive_sign);
    ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SNEGATIVESIGN, (void *)&l->negative_sign);

    ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_IINTLCURRDIGITS, (void *)&l->int_frac_digits);
    ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_ICURRDIGITS, (void *)&l->frac_digits);
    ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_IPOSSYMPRECEDES, (void *)&l->p_cs_precedes);
    ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_IPOSSEPBYSPACE, (void *)&l->p_sep_by_space);
    ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_INEGSYMPRECEDES, (void *)&l->n_cs_precedes);
    ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_INEGSEPBYSPACE, (void *)&l->n_sep_by_space);
    ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_IPOSSIGNPOSN, (void *)&l->p_sign_posn);
    ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_INEGSIGNPOSN, (void *)&l->n_sign_posn);

    return ret;
}
Exemplo n.º 5
0
/*------------------------------------------------
  get locale information by ANSI
--------------------------------------------------*/
int MyGetLocaleInfoA(int ilang, int codepage,
	LCTYPE lctype, char* dst, int n)
{
	int r;
	LCID locale;
	
	*dst = 0;
	locale = MAKELCID((WORD)ilang, SORT_DEFAULT);
	
	if(GetVersion() & 0x80000000) // 95/98/Me
		r = GetLocaleInfoA(locale, lctype, dst, n);
	else  // NT4/2000/XP
	{
		WCHAR buf[80];
		r = GetLocaleInfoW(locale, lctype, buf, 80);
		if(r)
		{
			int codepage = GetCodePage(GetUserDefaultLangID());
			r = WideCharToMultiByte(codepage, 0, buf, -1, dst, n,
				NULL, NULL);
		}
	}
	
	return r;
}
Exemplo n.º 6
0
//
// Convert TAutoVal to TUString, used by TAutoString contructor and assignment
//
TAutoVal::operator TUString*()
{
  BSTR v;
  HRESULT stat;
  LCID lcid = MAKELCID(LangUserDefault, SORT_DEFAULT);

  switch (vt) {
  case atByte:     stat = ::VarBstrFromUI1(bVal, lcid,0, &v); break;
  case atShort:    stat = ::VarBstrFromI2(iVal,  lcid,0, &v); break;
  case atLong:     stat = ::VarBstrFromI4(lVal,  lcid,0, &v); break;
  case atFloat:    stat = ::VarBstrFromR4(fltVal,lcid,0, &v); break;
  case atDouble:   stat = ::VarBstrFromR8(dblVal,lcid,0, &v); break;
  case atCurrency: stat = ::VarBstrFromCy(cyVal ,lcid,0, &v); break;
  case atDatetime: stat = ::VarBstrFromDate(date,lcid,0, &v); break;
  case atString:   if (bstrVal) vt = atLoanedBSTR;
             return (s.Holder=TUString::Create(bstrVal, true, GetLanguage()));
  case atObject:   stat = ::VarBstrFromDisp(pdispVal,GetLocale(),0, &v); break;
  case atBool:     stat = ::VarBstrFromBool(boolVal,lcid,0, &v); break;
  case atByRef+atByte:     stat = ::VarBstrFromUI1(*pbVal, lcid,0, &v); break;
  case atByRef+atShort:    stat = ::VarBstrFromI2(*piVal,  lcid,0, &v); break;
  case atByRef+atLong:     stat = ::VarBstrFromI4(*plVal,  lcid,0, &v); break;
  case atByRef+atFloat:    stat = ::VarBstrFromR4(*pfltVal,lcid,0, &v); break;
  case atByRef+atDouble:   stat = ::VarBstrFromR8(*pdblVal,lcid,0, &v); break;
  case atByRef+atCurrency: stat = ::VarBstrFromCy(*pcyVal ,lcid,0, &v); break;
  case atByRef+atDatetime: stat = ::VarBstrFromDate(*pdate,lcid,0, &v); break;
  case atByRef+atString:   if (*pbstrVal) vt = atByRef+atLoanedBSTR;
           return (s.Holder=TUString::Create(*pbstrVal, true, GetLanguage()));
  case atByRef+atBool:     stat = ::VarBstrFromBool(*pbool,lcid,0,&v);break;
  default:         stat = (HRESULT)-1;
  }
  if (stat != HR_NOERROR)
    TXAuto::Raise(TXAuto::xConversionFailure);
  return TUString::Create(v, false, LANGIDFROMLCID(lcid));
}
Exemplo n.º 7
0
//
// Convert TAutoVal to string, high performance if already of string type
//
TAutoVal::operator owl::tstring()
{
  BSTR v;
  HRESULT stat;
  LCID lcid = MAKELCID(LangUserDefault, SORT_DEFAULT);

  switch (vt) {
  case atByte:     stat = ::VarBstrFromUI1(bVal, lcid,0, &v); break;
  case atShort:    stat = ::VarBstrFromI2(iVal,  lcid,0, &v); break;
  case atLong:     stat = ::VarBstrFromI4(lVal,  lcid,0, &v); break;
  case atFloat:    stat = ::VarBstrFromR4(fltVal,lcid,0, &v); break;
  case atDouble:   stat = ::VarBstrFromR8(dblVal,lcid,0, &v); break;
  case atCurrency: stat = ::VarBstrFromCy(cyVal ,lcid,0, &v); break;
  case atDatetime: stat = ::VarBstrFromDate(date,lcid,0, &v); break;
  case atString:   return owl::tstring(TString(bstrVal));
  case atObject:           stat = ::VarBstrFromDisp(pdispVal,GetLocale(),0, &v); break;
  case atBool:             stat = ::VarBstrFromBool(boolVal,lcid,0, &v); break;
  case atByRef+atByte:     stat = ::VarBstrFromUI1(*pbVal, lcid,0, &v); break;
  case atByRef+atShort:    stat = ::VarBstrFromI2(*piVal,  lcid,0, &v); break;
  case atByRef+atLong:     stat = ::VarBstrFromI4(*plVal,  lcid,0, &v); break;
  case atByRef+atFloat:    stat = ::VarBstrFromR4(*pfltVal,lcid,0, &v); break;
  case atByRef+atDouble:   stat = ::VarBstrFromR8(*pdblVal,lcid,0, &v); break;
  case atByRef+atCurrency: stat = ::VarBstrFromCy(*pcyVal ,lcid,0, &v); break;
  case atByRef+atDatetime: stat = ::VarBstrFromDate(*pdate,lcid,0, &v); break;
  case atByRef+atString:   return owl::tstring(TString(*pbstrVal));
  case atByRef+atBool:     stat = ::VarBstrFromBool(*pbool,lcid,0,&v); break;
  default:         stat = (HRESULT)-1;
  }
  if (stat != HR_NOERROR)
    TXAuto::Raise(TXAuto::xConversionFailure);
  owl::tstring s((TString)v);
  ::SysFreeString(v);
  return s;
}
Exemplo n.º 8
0
void
_gdk_windowing_init (void)
{
  gchar buf[10];

  if (getenv ("GDK_IGNORE_WINTAB") != NULL)
    _gdk_input_ignore_wintab = TRUE;
  else if (getenv ("GDK_USE_WINTAB") != NULL)
    _gdk_input_ignore_wintab = FALSE;

  if (gdk_synchronize)
    GdiSetBatchLimit (1);

  _gdk_app_hmodule = GetModuleHandle (NULL);
  _gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
  _gdk_input_locale = GetKeyboardLayout (0);
  _gdk_input_locale_is_ime = ImmIsIME (_gdk_input_locale);
  GetLocaleInfo (MAKELCID (LOWORD (_gdk_input_locale), SORT_DEFAULT),
		 LOCALE_IDEFAULTANSICODEPAGE,
		 buf, sizeof (buf));
  _gdk_input_codepage = atoi (buf);
  GDK_NOTE (EVENTS, g_print ("input_locale:%p, codepage:%d\n",
			     _gdk_input_locale, _gdk_input_codepage));

  CoInitialize (NULL);

  _gdk_selection = gdk_atom_intern_static_string ("GDK_SELECTION");
  _wm_transient_for = gdk_atom_intern_static_string ("WM_TRANSIENT_FOR");
  _targets = gdk_atom_intern_static_string ("TARGETS");
  _delete = gdk_atom_intern_static_string ("DELETE");
  _save_targets = gdk_atom_intern_static_string ("SAVE_TARGETS");
  _utf8_string = gdk_atom_intern_static_string ("UTF8_STRING");
  _text = gdk_atom_intern_static_string ("TEXT");
  _compound_text = gdk_atom_intern_static_string ("COMPOUND_TEXT");
  _text_uri_list = gdk_atom_intern_static_string ("text/uri-list");
  _text_html = gdk_atom_intern_static_string ("text/html");
  _image_png = gdk_atom_intern_static_string ("image/png");
  _image_jpeg = gdk_atom_intern_static_string ("image/jpeg");
  _image_bmp = gdk_atom_intern_static_string ("image/bmp");
  _image_gif = gdk_atom_intern_static_string ("image/gif");

  _local_dnd = gdk_atom_intern_static_string ("LocalDndSelection");
  _gdk_win32_dropfiles = gdk_atom_intern_static_string ("DROPFILES_DND");
  _gdk_ole2_dnd = gdk_atom_intern_static_string ("OLE2_DND");

  /* MS Office 2007, at least, offers images in common file formats
   * using clipboard format names like "PNG" and "JFIF". So we follow
   * the lead and map the GDK target name "image/png" to the clipboard
   * format name "PNG" etc.
   */
  _cf_png = RegisterClipboardFormat ("PNG");
  _cf_jfif = RegisterClipboardFormat ("JFIF");
  _cf_gif = RegisterClipboardFormat ("GIF");

  _cf_url = RegisterClipboardFormat ("UniformResourceLocatorW");
  _cf_html_format = RegisterClipboardFormat ("HTML Format");
  _cf_text_html = RegisterClipboardFormat ("text/html");

  _gdk_win32_selection_init ();
}
Exemplo n.º 9
0
void CGitPropertyPage::Time64ToTimeString(__time64_t time, TCHAR * buf, size_t buflen) const
{
	struct tm newtime;
	SYSTEMTIME systime;

	LCID locale = LOCALE_USER_DEFAULT;
	if (!CRegDWORD(_T("Software\\TortoiseGit\\UseSystemLocaleForDates"), TRUE))
		locale = MAKELCID((WORD)CRegStdDWORD(_T("Software\\TortoiseGit\\LanguageID"), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)), SORT_DEFAULT);

	*buf = '\0';
	if (time)
	{
		TCHAR timebuf[MAX_STRING_LENGTH] = { 0 };
		TCHAR datebuf[MAX_STRING_LENGTH] = { 0 };
		_localtime64_s(&newtime, &time);

		systime.wDay = (WORD)newtime.tm_mday;
		systime.wDayOfWeek = (WORD)newtime.tm_wday;
		systime.wHour = (WORD)newtime.tm_hour;
		systime.wMilliseconds = 0;
		systime.wMinute = (WORD)newtime.tm_min;
		systime.wMonth = (WORD)newtime.tm_mon+1;
		systime.wSecond = (WORD)newtime.tm_sec;
		systime.wYear = (WORD)newtime.tm_year+1900;
		if (CRegStdDWORD(_T("Software\\TortoiseGit\\LogDateFormat")) == 1)
			GetDateFormat(locale, DATE_SHORTDATE, &systime, NULL, datebuf, MAX_STRING_LENGTH);
		else
			GetDateFormat(locale, DATE_LONGDATE, &systime, NULL, datebuf, MAX_STRING_LENGTH);
		GetTimeFormat(locale, 0, &systime, NULL, timebuf, MAX_STRING_LENGTH);
		*buf = '\0';
		_tcsncat_s(buf, buflen, datebuf, MAX_STRING_LENGTH-1);
		_tcsncat_s(buf, buflen, _T(" "), MAX_STRING_LENGTH-1);
		_tcsncat_s(buf, buflen, timebuf, MAX_STRING_LENGTH-1);
	}
}
Exemplo n.º 10
0
HRESULT double_to_string(double n, jsstr_t **str)
{
    const WCHAR InfinityW[] = {'-','I','n','f','i','n','i','t','y',0};

    if(isnan(n)) {
        *str = jsstr_nan();
    }else if(isinf(n)) {
        *str = jsstr_alloc(n<0 ? InfinityW : InfinityW+1);
    }else if(is_int32(n)) {
        *str = int_to_string(n);
    }else {
        VARIANT strv, v;
        HRESULT hres;

        /* FIXME: Don't use VariantChangeTypeEx */
        V_VT(&v) = VT_R8;
        V_R8(&v) = n;
        V_VT(&strv) = VT_EMPTY;
        hres = VariantChangeTypeEx(&strv, &v, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
        if(FAILED(hres))
            return hres;

        *str = jsstr_alloc(V_BSTR(&strv));
        SysFreeString(V_BSTR(&strv));
    }

    return *str ? S_OK : E_OUTOFMEMORY;
}
Exemplo n.º 11
0
/*------------------------------------------------
  GetTimeFormat() for 95/NT
--------------------------------------------------*/
int MyGetTimeFormatW(int ilang, int codepage,
	DWORD dwFlags, CONST SYSTEMTIME *t,
	wchar_t* fmt, wchar_t* dst, int n)
{
	int r;
	LCID Locale;
	
	*dst = 0;
	Locale = MAKELCID((WORD)ilang, SORT_DEFAULT);
	if(GetVersion() & 0x80000000) // 95
	{
		char buf[80], afmt[40];
		if(fmt)
			WideCharToMultiByte(codepage, 0, fmt, -1,
				afmt, 39, NULL, NULL);
		r = GetTimeFormatA(Locale, dwFlags, t, fmt ? afmt : NULL, buf, 79);
		if(r)
			r = MultiByteToWideChar(codepage, 0, buf, -1, dst, n);
	}
	else  // NT
	{
		r = GetTimeFormatW(Locale, dwFlags, t, fmt, dst, n);
	}
	return r;
}
Exemplo n.º 12
0
static BOOL CALLBACK
LocalesEnumProc(LPTSTR lpLocale)
{
    LCID lcid;
    WCHAR lang[255];
    INT index;
    BOOL bNoShow = FALSE;

    lcid = wcstoul(lpLocale, NULL, 16);

    /* Display only languages with installed support */
    if (!IsValidLocale(lcid, LCID_INSTALLED))
        return TRUE;

    if (lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH), SORT_DEFAULT) ||
        lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT))
    {
        if (bSpain == FALSE)
        {
            LoadStringW(hInstance, IDS_SPAIN, lang, 255);
            bSpain = TRUE;
        }
        else
        {
            bNoShow = TRUE;
        }
    }
    else
    {
        GetLocaleInfoW(lcid, LOCALE_SLANGUAGE, lang, sizeof(lang)/sizeof(WCHAR));
    }

    if (bNoShow == FALSE)
    {
        index = SendMessageW(hList,
                             CB_ADDSTRING,
                             0,
                             (LPARAM)lang);

        SendMessageW(hList,
                     CB_SETITEMDATA,
                     index,
                     (LPARAM)lcid);
    }

    return TRUE;
}
Exemplo n.º 13
0
void
win32locale_test(void)
{
	nsresult			result;
	nsIWin32Locale*		win32Locale;
	nsAutoString		locale;
	LCID				loc_id;

	//
	// test with a simple locale
	//
    locale.AssignLiteral("en-US");
	loc_id = 0;

	result = CallCreateInstance(kWin32LocaleFactoryCID, &win32Locale);
	NS_ASSERTION(win32Locale!=NULL,"nsLocaleTest: factory_create_interface failed.");
	NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");

	result = win32Locale->GetPlatformLocale(locale,&loc_id);
	NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
	NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT),
		"nsLocaleTest: GetPlatformLocale failed.");


	//
	// test with a not so simple locale
	//
	locale.AssignLiteral("x-netscape");
	loc_id = 0;

	result = win32Locale->GetPlatformLocale(locale,&loc_id);
	NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
	NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(USER_DEFINED_PRIMARYLANG,USER_DEFINED_SUBLANGUAGE),SORT_DEFAULT),
		"nsLocaleTest: GetPlatformLocale failed.");


	locale.AssignLiteral("en");
	loc_id = 0;

	result = win32Locale->GetPlatformLocale(locale,&loc_id);
	NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
	NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT),SORT_DEFAULT),
		"nsLocaleTest: GetPlatformLocale failed.");

	win32Locale->Release();
}
Exemplo n.º 14
0
int __cdecl _tmain(int argc, TCHAR** argv)
{
    int nErrors;

    //init the static g_szModuleName:
    if(GetModuleFileName(NULL, g_szModuleName, FC_ARRAY_LEN(g_szModuleName))==0)
    {
	   FC_ASSERT_LASTERR(_T("GetModuleFileName"));
       return 1;
    }

    //do some core init:
    InitModuleCheckMemory(MODULE_NAME);

    if(FAILED(CoInitialize(NULL)))
    {
        _tprintf(CG_FATAL_MSGFMT,__FILE__,__LINE__,_T("CoInitialize failed"));
        nErrors = 1;
        goto Ende;
    }


    //always remove the module name.
    argv++;
    argc--;

    //get internal debug switches:
    if(argc>0 && !lstrcmpi(_T("-!bug"), argv[0]))
    {
        argv++;argc--;
        if(argc>0 && !lstrcmpi(_T("heap"), argv[0]))
        {
            argv++;argc--;
            if(argc>0)
            {
                FC_SetAllocBreak(_tcstoul(argv[0], NULL, 10));
                argv++;argc--;
            }
        }
    }


    //TODO get from registry
    if(!SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),SORT_DEFAULT)))
    {
        FC_ASSERT_LASTERR("SetThreadLocale()");
        //don't care any more...
    }

    //enter main backend routine:
    nErrors = CGPCmain(argc, argv);
    
    CoUninitialize();

Ende:
    ExitModuleCheckMemory(MODULE_NAME);
    return nErrors?1:0;
}
const char * Application::getCurrentLanguageCode()
{
    LANGID lid = GetUserDefaultUILanguage();
    const LCID locale_id = MAKELCID(lid, SORT_DEFAULT);
    static char code[3] = { 0 };
    GetLocaleInfoA(locale_id, LOCALE_SISO639LANGNAME, code, sizeof(code));
    code[2] = '\0';
    return code;
}
Exemplo n.º 16
0
// FindLocaleDirectory:  Search the provided path for one of the expected code page subdirectories
// Returns empty string on failure, or the full path to the c:\my\directory\1033\myrcfile.dll
static MyString FindLocaleDirectory(const MyString &path, const MyString &dllName)
{
    // We'll be checking for 3 different locales:  The user's default locale
    // The user's primary language locale, and english (in that order)
    const LCID lcidUser = MAKELCID(GetUserDefaultUILanguage(), SORT_DEFAULT);
    LCID rglcid[3] = {lcidUser, MAKELCID(MAKELANGID(PRIMARYLANGID(lcidUser), SUBLANG_DEFAULT), SORTIDFROMLCID(lcidUser)), ENGLISH_LCID};

    for (int i = 0; i < _countof(rglcid); i++)
    {
        LCID lcid = rglcid[i];
        // Turn the LCID into a string
        wchar_t wzNumBuf[12];
        _itow_s(lcid, wzNumBuf, _countof(wzNumBuf), 10);
        MyString localePath = MakePath(path, wzNumBuf, dllName);

        // Check to see if the file exists
        if (FileExists(localePath))
        {
            // make sure the console can support a codepage for this language.
            UINT ConsoleCP = GetConsoleOutputCP();
            
            // Dev10 #843375: For a GUI application, GetConsoleOutputCP returns 0
            // If that's the case, we don't care about capabilities of the console, 
            // since we're not outputting to the console, anyway...
            if ( ConsoleCP != 0 && lcid != ENGLISH_LCID )
            {
                LANGID LanguageID = MAKELANGID( lcid, SUBLANGID(lcid) );
                // we know the console cannot support arabic or hebrew (right to left scripts?)
                if( PRIMARYLANGID(LanguageID) == LANG_ARABIC || PRIMARYLANGID(LanguageID) == LANG_HEBREW )
                    continue;

                UINT LangOEMCodepage = GetCodePage(LanguageID, LOCALE_IDEFAULTCODEPAGE);
                UINT LangANSICodepage = GetCodePage(LanguageID, LOCALE_IDEFAULTANSICODEPAGE);

                // We can only support it if the console's code page is UTF8, OEM, or ANSI
                if( ConsoleCP != CP_UTF8 && ConsoleCP != LangOEMCodepage && ConsoleCP != LangANSICodepage )
                    continue;
            }

            return localePath;
        }
    }
    return W("");
}
Exemplo n.º 17
0
HRESULT OPCEngine::registerServer(void)
{ 
	_TRACE(TL_INF, TG_ENG, (_T("register server")));
	HRESULT res;

	// register COM Server object
	res = _Module.RegisterServer(FALSE);

	if (SUCCEEDED(res))
	{
		ICatRegister *cr;
		CATEGORYINFO catInfo[4];
		CATID catIDs[2];

		if (SUCCEEDED(res = ::CoCreateInstance(CLSID_StdComponentCategoriesMgr, 
			NULL, CLSCTX_ALL, IID_ICatRegister, (void **)&cr)))
		{
			// register category
			catInfo[0].catid = CATID_OPCDAServer10;
			catInfo[1].catid = CATID_OPCDAServer10;
			catInfo[2].catid = CATID_OPCDAServer20;
			catInfo[3].catid = CATID_OPCDAServer20;
			catInfo[0].lcid = MAKELCID( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) , SORT_DEFAULT);
			catInfo[1].lcid = MAKELCID( MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN),  SORT_DEFAULT);
			catInfo[2].lcid = MAKELCID( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) , SORT_DEFAULT);
			catInfo[3].lcid = MAKELCID( MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN),  SORT_DEFAULT);
			wcscpy(catInfo[0].szDescription, L"OPC Data Access Server V1.0A");
			wcscpy(catInfo[1].szDescription, L"OPC Daten Server V1.0A");
			wcscpy(catInfo[2].szDescription, L"OPC Data Access Server V2.0");
			wcscpy(catInfo[3].szDescription, L"OPC Daten Server V2.0");
			res = cr->RegisterCategories(4, catInfo);
			_TRACE(TL_INF, TG_ENG, (_T("register component categories [0x%X]"), res));

			// register server in categories
			catIDs[0] = CATID_OPCDAServer10;
			catIDs[1] = CATID_OPCDAServer20;
			res = cr->RegisterClassImplCategories(g_clsid, 2, catIDs);
			_TRACE(TL_INF, TG_ENG, (_T("register component implementations [0x%X]"), res));

			cr->Release();
		}
	}
	return res; 
} // registerServer
Exemplo n.º 18
0
static UINT setup_unix_locales(void)
{
    struct locale_name locale_name;
    // WCHAR buffer[128];
    WCHAR ctype_buff[128];
    char *locale;
    UINT unix_cp = 0;

    if ((locale = setlocale( LC_CTYPE, NULL )))
    {
        strcpynAtoW( ctype_buff, locale, sizeof(ctype_buff)/sizeof(WCHAR) );
        parse_locale_name( ctype_buff, &locale_name );
        lcid_LC_CTYPE = locale_name.lcid;
        unix_cp = locale_name.codepage;
    }
    if (!lcid_LC_CTYPE)  /* this one needs a default value */
        lcid_LC_CTYPE = MAKELCID( MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT), SORT_DEFAULT );

#if 0
    TRACE( "got lcid %04x (%d matches) for LC_CTYPE=%s\n",
           locale_name.lcid, locale_name.matches, debugstr_a(locale) );

#define GET_UNIX_LOCALE(cat) do \
    if ((locale = setlocale( cat, NULL ))) \
    { \
        strcpynAtoW( buffer, locale, sizeof(buffer)/sizeof(WCHAR) ); \
        if (!strcmpW( buffer, ctype_buff )) lcid_##cat = lcid_LC_CTYPE; \
        else { \
            parse_locale_name( buffer, &locale_name );  \
            lcid_##cat = locale_name.lcid; \
            TRACE( "got lcid %04x (%d matches) for " #cat "=%s\n",        \
                   locale_name.lcid, locale_name.matches, debugstr_a(locale) ); \
        } \
    } while (0)

    GET_UNIX_LOCALE( LC_COLLATE );
    GET_UNIX_LOCALE( LC_MESSAGES );
    GET_UNIX_LOCALE( LC_MONETARY );
    GET_UNIX_LOCALE( LC_NUMERIC );
    GET_UNIX_LOCALE( LC_TIME );
#ifdef LC_PAPER
    GET_UNIX_LOCALE( LC_PAPER );
#endif
#ifdef LC_MEASUREMENT
    GET_UNIX_LOCALE( LC_MEASUREMENT );
#endif
#ifdef LC_TELEPHONE
    GET_UNIX_LOCALE( LC_TELEPHONE );
#endif

#undef GET_UNIX_LOCALE

#endif // #if 0

    return unix_cp;
}
Exemplo n.º 19
0
static BOOL CALLBACK
LocalesEnumProc(PWSTR lpLocale)
{
    LCID lcid;
    WCHAR lang[255];
    INT index;
    BOOL bNoShow = FALSE;

    lcid = wcstoul(lpLocale, NULL, 16);

    if (lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH), SORT_DEFAULT) ||
        lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT))
    {
        if (bSpain == FALSE)
        {
            LoadStringW(hApplet, IDS_SPAIN, lang, 255);
            bSpain = TRUE;
        }
        else
        {
            bNoShow = TRUE;
        }
    }
    else
    {
        GetLocaleInfoW(lcid, LOCALE_SLANGUAGE, lang, sizeof(lang)/sizeof(WCHAR));
    }

    if (bNoShow == FALSE)
    {
    index = SendMessageW(hLangList,
                         CB_ADDSTRING,
                         0,
                         (LPARAM)lang);

    SendMessageW(hLangList,
                 CB_SETITEMDATA,
                 index,
                 (LPARAM)lcid);
    }

    return TRUE;
}
Exemplo n.º 20
0
NTSTATUS NTAPI NtQueryDefaultLocale(
	BOOLEAN ThreadOrSystem,
	PLCID Locale)
{
	dprintf("%x %p\n", ThreadOrSystem, Locale);

	LCID lcid = MAKELCID( MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT );

	return copy_to_user( Locale, &lcid, sizeof lcid );
}
Exemplo n.º 21
0
int GBKToGB2312(LPCSTR lpMultiByteStrSrc, int cbMultiByteSrc, LPSTR lpMultiByteStrDst, int cbMultiByteDst)
{
	DWORD dwLCID = MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), SORT_CHINESE_BIG5);
	int nResult = 0;
	nResult = ::LCMapString(dwLCID, LCMAP_SIMPLIFIED_CHINESE, lpMultiByteStrSrc, cbMultiByteSrc, lpMultiByteStrDst, cbMultiByteDst);
	if(nResult == 0)
	{
		AfxTrace("LCMapString Failed. Error code = %d\n", GetLastError());
	}
	return nResult;
}
Exemplo n.º 22
0
LPTSTR GetShortNameOfLayout(HKL hklLayout)
{
	TCHAR szLI[20];
	LPTSTR ptszLiShort = (LPTSTR)mir_alloc(3*sizeof(TCHAR));
	DWORD dwLcid = MAKELCID(hklLayout, 0);
	GetLocaleInfo(dwLcid, LOCALE_SISO639LANGNAME, szLI, 10);
	ptszLiShort[0] = toupper(szLI[0]);
	ptszLiShort[1] = toupper(szLI[1]);
	ptszLiShort[2] = 0;
	return ptszLiShort;
}
Exemplo n.º 23
0
// Convert Language ID to CodePage
UINT AwtMenuItem::LangToCodePage(LANGID idLang)
{
    TCHAR strCodePage[MAX_ACP_STR_LEN];
    // use the LANGID to create a LCID
    LCID idLocale = MAKELCID(idLang, SORT_DEFAULT);
    // get the ANSI code page associated with this locale
    if (GetLocaleInfo(idLocale, LOCALE_IDEFAULTANSICODEPAGE, strCodePage, sizeof(strCodePage)/sizeof(TCHAR)) > 0 )
        return _ttoi(strCodePage);
    else
        return GetACP();
}
Exemplo n.º 24
0
/* ECMA-262 3rd Edition    9.8 */
HRESULT to_string(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, BSTR *str)
{
    const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
    const WCHAR nullW[] = {'n','u','l','l',0};
    const WCHAR trueW[] = {'t','r','u','e',0};
    const WCHAR falseW[] = {'f','a','l','s','e',0};

    switch(V_VT(v)) {
    case VT_EMPTY:
        *str = SysAllocString(undefinedW);
        break;
    case VT_NULL:
        *str = SysAllocString(nullW);
        break;
    case VT_I4:
        *str = int_to_bstr(V_I4(v));
        break;
    case VT_R8: {
        VARIANT strv;
        HRESULT hres;

        V_VT(&strv) = VT_EMPTY;
        hres = VariantChangeTypeEx(&strv, v, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
        if(FAILED(hres))
            return hres;

        *str = V_BSTR(&strv);
        return S_OK;
    }
    case VT_BSTR:
        *str = SysAllocString(V_BSTR(v));
        break;
    case VT_DISPATCH: {
        VARIANT prim;
        HRESULT hres;

        hres = to_primitive(ctx, v, ei, &prim);
        if(FAILED(hres))
            return hres;

        hres = to_string(ctx, &prim, ei, str);
        VariantClear(&prim);
        return hres;
    }
    case VT_BOOL:
        *str = SysAllocString(V_BOOL(v) ? trueW : falseW);
        break;
    default:
        FIXME("unsupported vt %d\n", V_VT(v));
        return E_NOTIMPL;
    }

    return *str ? S_OK : E_OUTOFMEMORY;
}
Exemplo n.º 25
0
static char *
lang_name (int lang)
{
  LCID lcid = MAKELCID (lang, SORT_DEFAULT);
  static char retval[10];

  if (!GetLocaleInfo (lcid, LOCALE_SISO639LANGNAME, retval, G_N_ELEMENTS (retval)))
    sprintf (retval, "%#02x", lang);

  return retval;
}
Exemplo n.º 26
0
int CMultiLanguage::PrintThreeLetterLanguageCodeList( void )
{
    LANGID  id[] =
    {
        0x0436,0x041c,0x0401,0x0801,0x0c01,0x1001,0x1401,0x1801,0x1c01,0x2001,0x2401,0x2801,
        0x2c01,0x3001,0x3401,0x3801,0x3c01,0x4001,0x042b,0x042c,0x082c,0x042d,0x0423,0x0445,
        0x141a,0x0402,0x0455,0x0403,0x0404,0x0804,0x0c04,0x1004,0x1404,0x041a,0x101a,0x0405,
        0x0406,0x0465,0x0413,0x0813,0x0409,0x0809,0x0c09,0x1009,0x1409,0x1809,0x1c09,0x2009,
        0x2409,0x2809,0x2c09,0x3009,0x3409,0x0425,0x0438,0x0429,0x040b,0x040c,0x080c,0x0c0c,
        0x100c,0x140c,0x180c,0x0456,0x0437,0x0407,0x0807,0x0c07,0x1007,0x1407,0x0408,0x0447,
        0x040d,0x0439,0x040e,0x040f,0x0421,0x0434,0x0435,0x0410,0x0810,0x0411,0x044b,0x0457,
        0x0412,0x0812,0x0440,0x0426,0x0427,0x0827,0x042f,0x043e,0x083e,0x044c,0x0481,0x043a,
        0x044e,0x0450,0x0414,0x0814,0x0415,0x0416,0x0816,0x0446,0x046b,0x086b,0x0c6b,0x0418,
        0x0419,0x044f,0x043b,0x083b,0x0c3b,0x103b,0x143b,0x183b,0x1c3b,0x203b,0x243b,0x0c1a,
        0x1c1a,0x081a,0x181a,0x046c,0x0432,0x041b,0x0424,0x040a,0x080a,0x0c0a,0x100a,0x140a,
        0x180a,0x1c0a,0x200a,0x240a,0x280a,0x2c0a,0x300a,0x340a,0x380a,0x3c0a,0x400a,0x440a,
        0x480a,0x4c0a,0x500a,0x0430,0x0441,0x041d,0x081d,0x045a,0x0449,0x0444,0x044a,0x041e,
        0x041f,0x0422,0x0420,0x0820,0x0443,0x0843,0x042a,0x0452
    };

    LCID    lcid, lcidMain;
    int     nResult;
    TCHAR   szLangCode[4];
    TCHAR   szLangCodeMain[4];

    TRACE(_T("Identifier\tThree-letter Abbrev. lang. Name\n"));
    for ( int i=0; i< sizeof(id)/sizeof(id[0]); i++ )
    {
        lcid = MAKELCID( id[i], SORT_DEFAULT );
        LANGID langid = id[i];      // Without sub language
        int nPrimaryLang = PRIMARYLANGID(langid);
        int nSubLang = SUBLANGID(langid);
        lcidMain = MAKELCID(MAKELANGID(nPrimaryLang, SUBLANG_NEUTRAL), SORT_DEFAULT);
        lstrcpy(szLangCode, _T("==="));
        lstrcpy(szLangCodeMain, _T("==="));
        nResult = ::GetLocaleInfo(lcid, LOCALE_SABBREVLANGNAME, szLangCode, 4);
        nResult = ::GetLocaleInfo(lcidMain, LOCALE_SABBREVLANGNAME, szLangCodeMain, 4);
        TRACE(_T("0x%04X,\t%s,\t%s\n"), lcid, szLangCode, szLangCodeMain );
    }
    return 0;
}
Exemplo n.º 27
0
///////////////////////////////////////////////////////////////////////////////
// Fills ``info`` with the currently installed keyboard layouts
// Based on http://blogs.msdn.com/michkap/archive/2004/12/05/275231.aspx.
void GetKeyboardLayouts(KeyboardLayoutInfo* info)
{
	memset(info, 0, sizeof(KeyboardLayoutInfo));
	info->count = GetKeyboardLayoutList(MAX_LAYOUTS, info->hkls);
	for(UINT i = 0; i < info->count; i++)
	{
		LANGID language = (LANGID)(((UINT)info->hkls[i]) & 0x0000FFFF); // bottom 16 bit of HKL
		LCID locale = MAKELCID(language, SORT_DEFAULT);
		GetLocaleInfo(locale, LOCALE_SLANGUAGE, info->names[i], MAXLEN);
		info->inUse[i] = TRUE;
	}
}
Exemplo n.º 28
0
CString GetLocaleString(LCTYPE lctype, LANGID langid)
{
    LCID lcid = MAKELCID(langid, SORT_DEFAULT);

    int len = ::GetLocaleInfo(lcid, lctype, NULL, 0);
    CString s;

    ::GetLocaleInfo(lcid, lctype, s.GetBuffer(len), len);
    s.ReleaseBuffer();

    return s;
}
Exemplo n.º 29
0
void LanguageChanged(HWND hwndDlg)
{
	ULONG_PTR LangID = (ULONG_PTR)GetKeyboardLayout(0);
	char Lang[3] = { 0 };
	if (LangID != oldLangID) {
		oldLangID = LangID;
		GetLocaleInfoA(MAKELCID((LangID & 0xffffffff), SORT_DEFAULT), LOCALE_SABBREVLANGNAME, Lang, 2);
		Lang[0] = toupper(Lang[0]);
		Lang[1] = tolower(Lang[1]);
		SetDlgItemTextA(hwndDlg, IDC_LANG, Lang);
	}
}
Exemplo n.º 30
0
/*
 * Convert UTF-8 to a platform string 
 */
int 
convertUft8ToPlatformString(char* utf8_str, int utf8_len, char* platform_str, int platform_len) {
    LANGID langID;
    LCID localeID;
    TCHAR strCodePage[7];	// ANSI code page id
    UINT codePage;
    int wlen, plen;
    WCHAR* wstr;
        
    /*
     * Get the code page for this locale
     */
    langID = LANGIDFROMLCID(GetUserDefaultLCID());  
    localeID = MAKELCID(langID, SORT_DEFAULT);
    if (GetLocaleInfo(localeID, LOCALE_IDEFAULTANSICODEPAGE, 
		      strCodePage, sizeof(strCodePage)/sizeof(TCHAR)) > 0 ) {
        codePage = atoi(strCodePage);
    } else {
        codePage = GetACP();
    }

    /*
     * To convert the string to platform encoding we must first convert
     * to unicode, and then convert to the platform encoding
     */
    plen = -1;
    wlen = MultiByteToWideChar(CP_UTF8, 0, utf8_str, utf8_len, NULL, 0);
    if (wlen > 0) {
        wstr = (WCHAR*)malloc(wlen * sizeof(WCHAR));
	if (wstr != NULL) {
    	    if (MultiByteToWideChar(CP_UTF8, 
                                    0, 
                                    utf8_str, 
                                    utf8_len, 
                                    wstr, wlen) > 0) {
     	        plen = WideCharToMultiByte(codePage, 
                                           0, 
                                           wstr, 
                                           wlen, 
                                           platform_str, 
                                           platform_len, 
                                           NULL, 
                                           NULL);   
	  	if (plen >= 0) {	
    	 	    platform_str[plen] = '\0';
		}
		free(wstr);
	    }
	}
    }
    return plen;
}