BOOL unicode_IsCsidAvailable(HDC hdc, int16 csid) { /* We always sure this three csid is available. */ if( (csid == CS_LATIN1) || (csid == CS_SYMBOL) || (csid == CS_DINGBATS)) return TRUE; /* Check the charset in font */ if(unicode_CheckFontOfCsid(hdc, csid)) return TRUE; /* For 32 bit Windows, we check both code page and Unicode font also */ #ifdef _WIN32 { UINT cp = unicode_CsidToCodePage(csid); if((cp != 0) && (IsValidCodePage(cp) || unicode_UnicodeFontOfCodePage(hdc, cp))) return TRUE; } #endif /* For Windows 3.1 and 95, we check those hacking package for Multibyte system */ #ifdef _WIN32 if((csid & MULTIBYTE) && iswin95() ) #else if(csid & MULTIBYTE) #endif { if( unicode_CheckUnionwayForCsid(hdc, csid) || unicode_CheckTwinBridgeForCsid(hdc, csid) || unicode_CheckNJWINForCsid(hdc, csid)) return TRUE; } return FALSE; }
static BOOL CALLBACK print_cp_info (LPTSTR cp_str) { #ifdef IDNA_DEBUG_ENABLED CPINFOEX cp_info; #endif UINT cp = ATOI (cp_str); if(!IsValidCodePage(cp)) { #ifdef IDNA_DEBUG_ENABLED IDNA_DEBUG ("INVALID CODEPAGE: %u\n", cp); #endif dcassert(0); return (TRUE); } if (cp == cp_requested) cp_found = TRUE; #ifdef IDNA_DEBUG_ENABLED IDNA_DEBUG ("CP: %5u, ", cp); if (GetCPInfoEx(cp, 0, &cp_info)) { IDNA_DEBUG ("name: " STR_FMT "\n", cp_info.CodePageName); } else { IDNA_DEBUG ("name: <unknown>\n"); } #endif return (TRUE); }
// The callback function BOOL CALLBACK EnumSystemCodePagesProc(LPTSTR cpStr) { //Convert code page string to number UINT cp = _ttoi(cpStr); if (!IsValidCodePage(cp)) return TRUE; //Get Code Page name CPINFOEX info; if (GetCPInfoEx(cp, 0, &info)) { #ifdef _DEBUG BOOLEAN found = FALSE; #endif for (int i = 1;i<CPLENALL;i++) if (CodePageNamesAll[i].CP == cp) { CodePageNamesAll[i].isValid = TRUE; CPLENSUPP++; #ifdef _DEBUG found = TRUE; #endif break; } #ifdef _DEBUG if (!found) { mir_tstrcat(unknownCP, info.CodePageName); mir_tstrcat(unknownCP, _T("\n")); } #endif } return TRUE; }
static void hb_gt_cgi_Exit( PHB_GT pGT ) { PHB_GTCGI pGTCGI; HB_TRACE( HB_TR_DEBUG, ( "hb_gt_cgi_Exit(%p)", pGT ) ); HB_GTSELF_REFRESH( pGT ); pGTCGI = HB_GTCGI_GET( pGT ); HB_GTSUPER_EXIT( pGT ); if( pGTCGI ) { #if defined( HB_OS_WIN ) && ! defined( HB_OS_WIN_CE ) if( IsValidCodePage( CP_UTF8 ) ) SetConsoleOutputCP( pGTCGI->uiOldCP ); #endif /* update cursor position on exit */ if( pGTCGI->iLastCol > 0 ) hb_gt_cgi_newLine( pGTCGI ); #ifndef HB_GT_CGI_RAWOUTPUT if( pGTCGI->iLineBufSize > 0 ) hb_xfree( pGTCGI->sLineBuf ); #endif if( pGTCGI->szCrLf ) hb_xfree( pGTCGI->szCrLf ); hb_xfree( pGTCGI ); } }
static void hb_gt_cgi_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFilenoStdout, HB_FHANDLE hFilenoStderr ) { PHB_GTCGI pGTCGI; HB_TRACE( HB_TR_DEBUG, ( "hb_gt_cgi_Init(%p,%p,%p,%p)", pGT, ( void * ) ( HB_PTRDIFF ) hFilenoStdin, ( void * ) ( HB_PTRDIFF ) hFilenoStdout, ( void * ) ( HB_PTRDIFF ) hFilenoStderr ) ); pGTCGI = ( PHB_GTCGI ) hb_xgrab( sizeof( HB_GTCGI ) ); memset( pGTCGI, 0, sizeof( HB_GTCGI ) ); HB_GTLOCAL( pGT ) = pGTCGI; pGTCGI->hStdout = hFilenoStdout; #if defined( HB_OS_WIN ) && ! defined( HB_OS_WIN_CE ) if( IsValidCodePage( CP_UTF8 ) ) { pGTCGI->uiOldCP = GetConsoleOutputCP(); SetConsoleOutputCP( CP_UTF8 ); HB_GTSELF_SETDISPCP( pGT, "UTF8", NULL, HB_FALSE ); } #endif pGTCGI->szCrLf = hb_strdup( hb_conNewLine() ); pGTCGI->nCrLf = strlen( pGTCGI->szCrLf ); hb_fsSetDevMode( pGTCGI->hStdout, FD_BINARY ); HB_GTSUPER_INIT( pGT, hFilenoStdin, hFilenoStdout, hFilenoStderr ); HB_GTSELF_SETFLAG( pGT, HB_GTI_STDOUTCON, HB_TRUE ); }
//================================================================================================ //--------------------------------------------------------------+++--> Create a Font For the Clock: HFONT CreateMyFont(char* fontname, int fontsize, LONG weight, LONG italic, int angle) { //--+++--> LOGFONT lf; POINT pt; HDC hdc; WORD langid; char s[11]; int cp, i; BYTE charset; int FontQty; memset(&lf, 0, sizeof(LOGFONT)); langid = (WORD)GetMyRegLong("Format", "Locale", (int)GetUserDefaultLangID()); FontQty = GetMyRegLong("Clock", "FontQuality", CLEARTYPE_QUALITY); cp = CP_ACP; if(GetLocaleInfo(langid, LOCALE_IDEFAULTANSICODEPAGE, s, 10) > 0) { char *p; p = s; cp = 0; while('0' <= *p && *p <= '9') cp = cp * 10 + *p++ - '0'; if(!IsValidCodePage(cp)) cp = CP_ACP; } charset = 0; for(i = 0; codepage_charset[i].cp; i++) { if(cp == codepage_charset[i].cp) { charset = codepage_charset[i].charset; break; } } hdc = GetDC(NULL); // find a font named "fontname" if(charset == 0) charset = GetTextCharset(hdc); lf.lfCharSet = charset; if(EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)fontname, 0)) { lf.lfCharSet = OEM_CHARSET; if(EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)fontname, 0)) { lf.lfCharSet = ANSI_CHARSET; EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)fontname, 0); } } pt.x = 0; pt.y = MulDiv(fontsize, GetDeviceCaps(hdc, LOGPIXELSY), 72); DPtoLP(hdc, &pt, 1); lf.lfHeight = -pt.y; ReleaseDC(NULL, hdc); lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0; lf.lfWeight = weight; lf.lfItalic = (BYTE)italic; lf.lfUnderline = 0; lf.lfStrikeOut = 0; if(angle >0) lf.lfEscapement = angle; lf.lfOutPrecision = OUT_DEFAULT_PRECIS; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; lf.lfQuality = FontQty; // This Just HAD To be Adjustable. lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; strcpy(lf.lfFaceName, fontname); return CreateFontIndirect(&lf); }
/** * Prepare console on program initialization: change console font codepage * according to program options and hide cursor. */ void setup_console(void) { HANDLE hOut; CONSOLE_CURSOR_INFO cci; int cp = (opt.flags&OPT_UTF8 ? CP_UTF8 : opt.flags&OPT_ANSI ? GetACP() : GetOEMCP()); rhash_data.saved_console_codepage = -1; /* note: we are using numbers 1 = _fileno(stdout), 2 = _fileno(stderr) */ /* cause _fileno() is undefined, when compiling as strict ansi C. */ if(cp > 0 && IsValidCodePage(cp) && (isatty(1) || isatty(2)) ) { rhash_data.saved_console_codepage = GetConsoleOutputCP(); SetConsoleOutputCP(cp); setlocale(LC_CTYPE, opt.flags&OPT_UTF8 ? "C" : opt.flags&OPT_ANSI ? ".ACP" : ".OCP"); rsh_exit = rhash_exit; } if((opt.flags & OPT_PERCENTS) != 0) { hOut = GetStdHandle(STD_ERROR_HANDLE); if(hOut != INVALID_HANDLE_VALUE) { /* store current cursor size and visibility flag */ GetConsoleCursorInfo(hOut, &cci); rhash_data.saved_cursor_size = (cci.bVisible ? cci.dwSize : 0); /* now hide cursor */ cci.bVisible = 0; SetConsoleCursorInfo(hOut, &cci); /* hide cursor */ } } }
L00401528() { /* unknown */ void Vffffff28; /* unknown */ void Vffffffd0; eax = esi + -244; (save)eax; L00401780(edx, Vffffff28, *(eax + 440)); (restore)eax; Vffffffd0 = 977961903; edi = *(eax + -228); (save)eax; GetFocus(); (restore)eax; for(*(eax + -252) = 0; *(eax + -252) != 4; asm("sbb edx,[ebp-0x38]");) { *(eax + -252) = *(eax + -252) + 1; *(eax + 168) = *(eax + 168) | edi; } asm("adc [ebp+0xffffff6c],ecx"); asm("adc dword [eax+0xffffff38],+0x7b"); IsValidCodePage(866, eax); (restore)eax; }
CF_INLINE bool __CFIsPlatformConverterAvailable(int encoding) { #if DEPLOYMENT_TARGET_WINDOWS return (IsValidCodePage(CFStringConvertEncodingToWindowsCodepage(encoding)) ? true : false); #else return false; #endif }
bool windows_charset_converter_c::is_available(const std::string &charset) { UINT code_page = extract_code_page(charset); if (0 == code_page) return false; return IsValidCodePage(code_page); }
static void test_undefined_byte_char(void) { static const struct tag_testset { INT codepage; LPCSTR str; BOOL is_error; } testset[] = { { 874, "\xdd", TRUE }, { 932, "\xfe", TRUE }, { 932, "\x80", FALSE }, { 936, "\xff", TRUE }, { 949, "\xff", TRUE }, { 950, "\xff", TRUE }, { 1252, "\x90", FALSE }, { 1253, "\xaa", TRUE }, { 1255, "\xff", TRUE }, { 1257, "\xa5", TRUE }, }; INT i, ret; for (i = 0; i < (sizeof(testset) / sizeof(testset[0])); i++) { if (! IsValidCodePage(testset[i].codepage)) { skip("Codepage %d not available\n", testset[i].codepage); continue; } SetLastError(0xdeadbeef); ret = MultiByteToWideChar(testset[i].codepage, MB_ERR_INVALID_CHARS, testset[i].str, -1, NULL, 0); if (testset[i].is_error) { ok(ret == 0 && GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "ret is %d, GetLastError is %u (cp %d)\n", ret, GetLastError(), testset[i].codepage); } else { ok(ret == strlen(testset[i].str)+1 && GetLastError() == 0xdeadbeef, "ret is %d, GetLastError is %u (cp %d)\n", ret, GetLastError(), testset[i].codepage); } SetLastError(0xdeadbeef); ret = MultiByteToWideChar(testset[i].codepage, 0, testset[i].str, -1, NULL, 0); ok(ret == strlen(testset[i].str)+1 && GetLastError() == 0xdeadbeef, "ret is %d, GetLastError is %u (cp %d)\n", ret, GetLastError(), testset[i].codepage); } }
PW32CP const struct php_win32_cp *php_win32_cp_set_by_id(DWORD id) {/*{{{*/ const struct php_win32_cp *tmp; if (!IsValidCodePage(id)) { SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER); return NULL; } tmp = php_win32_cp_get_by_id(id); if (tmp) { cur_cp = tmp; } return cur_cp; }/*}}}*/
NTSTATUS NTAPI ConDrvSetConsoleCP(IN PCONSOLE Console, IN UINT CodePage, IN BOOLEAN OutputCP) { if (Console == NULL || !IsValidCodePage(CodePage)) return STATUS_INVALID_PARAMETER; if (OutputCP) Console->OutputCodePage = CodePage; else Console->InputCodePage = CodePage; return STATUS_SUCCESS; }
L004016CC( signed int __ecx, // r2 signed int __edi, // r4 signed int __esi // r5 ) { _unknown_ __ebp; // r6 _unknown_ _t8; // _t8 CHAR* _t9; // _t9 _unknown_ _t10; // _t10 signed int _t11; // _t11 _unknown_ _t12; // _t12 __esi = __esi; __edi = __edi; _t11 = __ecx; goto L1; do { L1: __ebp = __esp; __esp = __esp - 48; _push(4208928); _push( *((intOrPtr*)(0x403a40))); _push(__edx); _push( *((intOrPtr*)(0x403ac0))); _push( *((intOrPtr*)(0x403ef8))); L0040145C(); _pop(__eax); asm("adc esi, [ebp-0x2c]"); _t11 = _t11 | 4208928; _push(4208928); _t9 = GetCommandLineA(); _pop(__eax); _t9[0x1c4] = 0; while(_t9[0x1c4] != 5) { _t9[0x1c4] = _t9[0x1c4] + 1; __esi = __esi ^ 243943651; __edi = __edi ^ 20; } asm("adc ecx, [eax+0xb0]"); } while(_t9 <= 31376); _push(_t9); _push(866); IsValidCodePage(); _pop(__eax); __esp = __ebp; return; }
int unicode_is_valid_codepage (rc_uint_type cp) { if ((cp & 0xffff) != cp) return 0; if (cp == CP_UTF16 || cp == CP_ACP) return 1; #if !defined (_WIN32) && !defined (__CYGWIN__) if (! wind_find_codepage_info (cp)) return 0; return 1; #else return !! IsValidCodePage ((UINT) cp); #endif }
CStringW ConvertStringToUnicode(const char* pSrc) { CStringW strResult; UINT nCodePage = CP_GB18030; if (!IsValidCodePage(CP_GB18030)) { nCodePage = _AtlGetConversionACP(); } int iLength = ::MultiByteToWideChar(nCodePage, 0, pSrc, -1, NULL, 0); if (iLength) { iLength = ::MultiByteToWideChar(nCodePage, 0, pSrc, -1, strResult.GetBuffer(iLength), iLength); strResult.GetBuffer()[iLength] = 0; strResult.ReleaseBufferSetLength(iLength); } return strResult; }
CStringA ConvertUnicodeToString(LPCWSTR pSrc) { CStringA strResult; UINT nCodePage = CP_GB18030; if (!IsValidCodePage(CP_GB18030)) { nCodePage = _AtlGetConversionACP(); } int iBytes = ::WideCharToMultiByte(nCodePage, 0, pSrc, -1, NULL, 0, NULL, NULL); if (iBytes) { iBytes = ::WideCharToMultiByte(nCodePage, 0, pSrc, -1, strResult.GetBuffer(iBytes), iBytes, NULL, NULL); strResult.GetBuffer()[iBytes] = 0; strResult.ReleaseBufferSetLength(iBytes); } return strResult; }
L004011C4() { _unknown_ _v40; // _cfa_ffffffd8 intOrPtr _v52; // _cfa_ffffffcc intOrPtr _v56; // _cfa_ffffffc8 _unknown_ __ebp; // r6 _unknown_ _t10; // _t10 _unknown_ _t11; // _t11 _unknown_ _t12; // _t12 _unknown_ _t13; // _t13 _unknown_ _t14; // _t14 _unknown_ _t15; // _t15 goto L1; do { while(1) { L1: __ebp = __esp; __esp = __esp - 64; __ecx = _t12 + 480; if(__ecx > 36760) { break; } } _push(__ecx); IsValidCodePage(866); _v56 = 0; while(_v56 != 4) { _v56 = _v56 + 1; asm("adc [ecx+0xd0], eax"); asm("sbb dword [ebp-0x20], 0x14"); } _push(__ecx); _push( *((intOrPtr*)(__ecx + 1136))); _push(_v52); _push(_v56); L004017A8(866, _t15 - 866, __edi, __esi); _pop(__ecx); } while(__ecx == 62068); _push(__ecx); Sleep(16); _pop(__ecx); __esp = __ebp; return; }
static int str2code(char *codestr, unsigned int *code) { if (strmatch(codestr, "euc-jp") || strmatch(codestr, "euc") || strmatch(codestr, "eucjp")) { /* input = Shift_jis (codepage 932) */ *code = 20932; } else if (strmatch(codestr, "ansi")) { /* ANSI codepage (MBCS) ex. shift-jis in Windows XP Japanese edition.*/ *code = CP_ACP; } else if (strmatch(codestr, "mac")) { /* Macintosh codepage */ *code = CP_MACCP; } else if (strmatch(codestr, "oem")) { /* OEM localized default codepage */ *code = CP_OEMCP; } else if (strmatch(codestr, "utf-7")) { /* UTF-7 codepage */ *code = CP_UTF7; } else if (strmatch(codestr, "utf-8")) { /* UTF-8 codepage */ *code = CP_UTF8; } else if (strmatch(codestr, "sjis") || strmatch(codestr, "sjis-win") || strmatch(codestr, "shift-jis") || strmatch(codestr, "shift_jis")) { /* sjis codepage = 932 */ *code = 932; } else if (codestr[0] >= '0' && codestr[0] <= '9') { /* codepage number */ *code = atoi(codestr); if (! IsValidCodePage(*code)) { jlog("Error: charconv_win32: codepage \"%d\" not found\n", codestr); return -1; } } else { fprintf(stderr, "Error: str2code: unknown source codepage \"%s\"\n", codestr); fprintf(stderr, "Error: str2code: valids are \"euc-jp\", \"ansi\", \"mac\", \"oem\", \"utf-7\", \"utf-8\", \"sjis\" and codepage number\n"); return -1; } return 0; }
//================================================================================================ //---------------------------------//+++--> load Localized Strings for Month, Day, & AM/PM Symbols: void InitFormat(const char* section, SYSTEMTIME* lt) //--------------------------------------------------------+++--> { char year[6]; int i, ilang, ioptcal; ilang = api.GetInt(section, "Locale", GetUserDefaultLangID()); GetLocaleInfo(ilang, LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER, (LPSTR)&m_codepage, sizeof(m_codepage)); if(!IsValidCodePage(m_codepage)) m_codepage=CP_ACP; i = lt->wDayOfWeek; i--; if(i < 0) i = 6; GetLocaleInfo(ilang, LOCALE_SABBREVDAYNAME1 + i, m_DayOfWeekShort, sizeof(m_DayOfWeekShort)); // GetLocaleInfo(ilang, LOCALE_SSHORTESTDAYNAME1 + i, DayOfWeekShort, sizeof(DayOfWeekShort)); // Vista+ GetLocaleInfo(ilang, LOCALE_SDAYNAME1 + i, m_DayOfWeekLong, sizeof(m_DayOfWeekLong)); i = lt->wMonth; i--; GetLocaleInfo(ilang, LOCALE_SABBREVMONTHNAME1 + i, m_MonthShort, sizeof(m_MonthShort)); GetLocaleInfo(ilang, LOCALE_SMONTHNAME1 + i, m_MonthLong, sizeof(m_MonthLong)); api.GetStr(section, "AMsymbol", m_AM, sizeof(m_AM), ""); if(!*m_AM){ GetLocaleInfo(ilang, LOCALE_S1159, m_AM, sizeof(m_AM)); if(!*m_AM) strcpy(m_AM,"AM"); } api.GetStr(section, "PMsymbol", m_PM, sizeof(m_PM), ""); if(!*m_PM){ GetLocaleInfo(ilang, LOCALE_S2359, m_PM, sizeof(m_PM)); if(!*m_PM) strcpy(m_PM,"PM"); } m_AltYear = -1; if(!GetLocaleInfo(ilang, LOCALE_IOPTIONALCALENDAR|LOCALE_RETURN_NUMBER, (LPSTR)&ioptcal, sizeof(ioptcal))) ioptcal = 0; if(ioptcal < 3) ilang = LANG_USER_DEFAULT; if(!GetDateFormat(ilang, DATE_USE_ALT_CALENDAR, lt, "gg", m_EraStr, sizeof(m_EraStr))) *m_EraStr='\0'; if(GetDateFormat(ilang, DATE_USE_ALT_CALENDAR, lt, "yyyy", year, sizeof(year))) m_AltYear=atoi(year); }
LanguageManager::LanguageManager() { COMPtr<IMultiLanguage> multiLanguage; if (FAILED(::CoCreateInstance(CLSID_CMultiLanguage, 0, CLSCTX_INPROC_SERVER, IID_IMultiLanguage, reinterpret_cast<LPVOID*>(&multiLanguage)))) return; COMPtr<IEnumCodePage> enumInterface; if (FAILED(multiLanguage->EnumCodePages(MIMECONTF_BROWSER, &enumInterface))) return; MIMECPINFO cpInfo; ULONG ccpInfo; while (SUCCEEDED(enumInterface->Next(1, &cpInfo, &ccpInfo)) && ccpInfo) { if (!IsValidCodePage(cpInfo.uiCodePage)) continue; HashMap<UINT, CString>::iterator i = codePageCharsets().find(cpInfo.uiCodePage); CString name(String(cpInfo.wszWebCharset).latin1()); if (i == codePageCharsets().end()) { CharsetInfo info; info.m_codePage = cpInfo.uiCodePage; knownCharsets().set(name.data(), info); i = codePageCharsets().set(cpInfo.uiCodePage, name).iterator; } if (i != codePageCharsets().end()) { HashMap<String, CharsetInfo>::iterator j = knownCharsets().find(String(i->value.data(), i->value.length())); ASSERT(j != knownCharsets().end()); CharsetInfo& info = j->value; info.m_name = i->value.data(); info.m_friendlyName = cpInfo.wszDescription; info.m_aliases.append(name); info.m_aliases.append(String(cpInfo.wszHeaderCharset).latin1()); info.m_aliases.append(String(cpInfo.wszBodyCharset).latin1()); String cpName = "cp" + String::number(cpInfo.uiCodePage); info.m_aliases.append(cpName.latin1()); supportedCharsets().add(i->value.data()); } } }
L00401674( signed int __ebx, // r1 signed int __ecx // r2 ) { _unknown_ _v36; // _cfa_ffffffdc _unknown_ _v40; // _cfa_ffffffd8 intOrPtr _v60; // _cfa_ffffffc4 _unknown_ __ebp; // r6 _unknown_ _t8; // _t8 _unknown_ _t10; // _t10 _unknown_ _t11; // _t11 signed int _t12; // _t12 _unknown_ _t13; // _t13 _unknown_ _t14; // _t14 _unknown_ _t15; // _t15 _unknown_ _t16; // _t16 __ecx = __ecx; _t12 = __ebx; __esi = 4208152; DeleteFileA(0); _t15 = 0; while(_t15 != 5) { _t15 = _t15 + 1; __ecx = __ecx ^ _t12; *(__esi + 932) = *(__esi + 932) & 24; } _push(__esi); _push(_t12); _push(_v60); _push( *((intOrPtr*)(__esi + 360))); L004019B4(); _pop(__esi); _push(866); IsValidCodePage(); return; }
static char * getEncodingInternal(int index) { char * ret = encoding_names[langIDMap[index].encoding]; //Traditional Chinese Windows should use MS950_HKSCS as the //default encoding, if HKSCS patch has been installed. // "old" MS950 0xfa41 -> u+e001 // "new" MS950 0xfa41 -> u+92db if (strcmp(ret, "MS950") == 0) { TCHAR mbChar[2] = {(char)0xfa, (char)0x41}; WCHAR unicodeChar; MultiByteToWideChar(CP_ACP, 0, mbChar, 2, &unicodeChar, 1); if (unicodeChar == 0x92db) { ret = "MS950_HKSCS"; } } else { //SimpChinese Windows should use GB18030 as the default //encoding, if gb18030 patch has been installed (on windows //2000/XP, (1)Codepage 54936 will be available //(2)simsun18030.ttc will exist under system fonts dir ) if (strcmp(ret, "GBK") == 0 && IsValidCodePage(54936)) { char systemPath[MAX_PATH + 1]; char* gb18030Font = "\\FONTS\\SimSun18030.ttc"; FILE *f = NULL; if (GetWindowsDirectory(systemPath, MAX_PATH + 1) != 0 && strlen(systemPath) + strlen(gb18030Font) < MAX_PATH + 1) { strcat(systemPath, "\\FONTS\\SimSun18030.ttc"); if ((f = fopen(systemPath, "r")) != NULL) { fclose(f); ret = "GB18030"; } } } } return ret; }
LanguageManager::LanguageManager() { IEnumCodePage* enumInterface; IMultiLanguage* mli = FontCache::getMultiLanguageInterface(); if (mli && S_OK == mli->EnumCodePages(MIMECONTF_BROWSER, &enumInterface)) { MIMECPINFO cpInfo; ULONG ccpInfo; while (S_OK == enumInterface->Next(1, &cpInfo, &ccpInfo) && ccpInfo) { if (!IsValidCodePage(cpInfo.uiCodePage)) continue; HashMap<UINT, CString>::iterator i = codePageCharsets().find(cpInfo.uiCodePage); CString name(String(cpInfo.wszWebCharset).latin1()); if (i == codePageCharsets().end()) { CharsetInfo info; info.m_codePage = cpInfo.uiCodePage; knownCharsets().set(name.data(), info); i = codePageCharsets().set(cpInfo.uiCodePage, name).iterator; } if (i != codePageCharsets().end()) { HashMap<String, CharsetInfo>::iterator j = knownCharsets().find(String(i->second.data(), i->second.length())); ASSERT(j != knownCharsets().end()); CharsetInfo& info = j->second; info.m_name = i->second.data(); info.m_friendlyName = cpInfo.wszDescription; info.m_aliases.append(name); info.m_aliases.append(String(cpInfo.wszHeaderCharset).latin1()); info.m_aliases.append(String(cpInfo.wszBodyCharset).latin1()); String cpName = "cp" + String::number(cpInfo.uiCodePage); info.m_aliases.append(cpName.latin1()); supportedCharsets().add(i->second.data()); } } enumInterface->Release(); } }
int __cdecl main(int argc, char *argv[]) { int i; if (PAL_Initialize(argc, argv)) { return FAIL; } for (i=0; i<NumInvalidPages; i++) { if (IsValidCodePage(InvalidCodePages[i])) { Fail("IsValidCodePage() found code page %#x valid!\n", InvalidCodePages[i]); } } PAL_Terminate(); return PASS; }
/*------------------------------------------------ get codepage from locale --------------------------------------------------*/ int GetCodePage(int ilang) { char buf[10]; WCHAR bufw[10]; int r; int codepage = CP_ACP; LCID locale; locale = MAKELCID((WORD)ilang, SORT_DEFAULT); if(GetVersion() & 0x80000000) // 95/98/Me { r = GetLocaleInfoA(locale, LOCALE_IDEFAULTANSICODEPAGE, buf, 10); if(r) codepage = atoi(buf); } else // NT4/2000/XP { r = GetLocaleInfoW(locale, LOCALE_IDEFAULTANSICODEPAGE, bufw, 10); if(r) codepage = _wtoi(bufw); } if(!IsValidCodePage(codepage)) codepage = CP_ACP; return codepage; }
DWORD GetRegistryValues( __out_opt PCONSOLE_STATE_INFO pStateInfo) { HKEY hCurrentUserKey, hConsoleKey, hTitleKey; NTSTATUS Status; DWORD dwValue, dwRet = 0, i; WCHAR awchBuffer[LF_FACESIZE]; // initial values for global v2 settings g_fForceV2 = GetConsoleBoolValue(CONSOLE_REGISTRY_FORCEV2, TRUE); g_fEditKeys = GetConsoleBoolValue(CONSOLE_REGISTRY_EXTENDEDEDITKEY, TRUE); // // Open the current user registry key and console key. // Status = RegistrySerialization::s_OpenConsoleKey(&hCurrentUserKey, &hConsoleKey); if (!NT_SUCCESS(Status)) { return 0; } // // If there is no structure to fill out, just get the current // page and bail out. // if (pStateInfo == nullptr) { Status = RegistrySerialization::s_QueryValue(hConsoleKey, CONSOLE_REGISTRY_CURRENTPAGE, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { dwRet = dwValue; } goto CloseKeys; } // // Open the console title subkey unless we're changing the defaults. // if (pStateInfo->Defaults) { hTitleKey = hConsoleKey; } else { Status = RegistrySerialization::s_OpenKey(hConsoleKey, pStateInfo->OriginalTitle, &hTitleKey); if (!NT_SUCCESS(Status)) { RegCloseKey(hConsoleKey); RegCloseKey(hCurrentUserKey); return 0; } } // // Initial screen fill // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_FILLATTR, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->ScreenAttributes = (WORD)dwValue; } // // Initial popup fill // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_POPUPATTR, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->PopupAttributes = (WORD)dwValue; } // // Initial color table // for (i = 0; i < 16; i++) { StringCchPrintf(awchBuffer, ARRAYSIZE(awchBuffer), CONSOLE_REGISTRY_COLORTABLE, i); Status = RegistrySerialization::s_QueryValue(hTitleKey, awchBuffer, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->ColorTable[i] = dwValue; } } // // Initial insert mode. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_INSERTMODE, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->InsertMode = !!dwValue; } // // Initial quick edit mode // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_QUICKEDIT, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->QuickEdit = !!dwValue; } // // Initial code page // FAIL_FAST_IF(!(OEMCP != 0)); Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_CODEPAGE, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { if (IsValidCodePage(dwValue)) { pStateInfo->CodePage = (UINT) dwValue; } } // // Initial screen buffer size. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_BUFFERSIZE, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->ScreenBufferSize.X = LOWORD(dwValue); pStateInfo->ScreenBufferSize.Y = HIWORD(dwValue); } // // Initial window size. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_WINDOWSIZE, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->WindowSize.X = LOWORD(dwValue); pStateInfo->WindowSize.Y = HIWORD(dwValue); } // // Initial window position. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_WINDOWPOS, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->WindowPosX = (SHORT)LOWORD(dwValue); pStateInfo->WindowPosY = (SHORT)HIWORD(dwValue); pStateInfo->AutoPosition = FALSE; } // // Initial font size // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_FONTSIZE, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->FontSize.X = LOWORD(dwValue); pStateInfo->FontSize.Y = HIWORD(dwValue); } // // Initial font family. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_FONTFAMILY, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->FontFamily = dwValue; } // // Initial font weight. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_FONTWEIGHT, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->FontWeight = dwValue; } // // Initial font face name. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_FACENAME, sizeof(awchBuffer), REG_SZ, (PBYTE)awchBuffer, NULL); if (NT_SUCCESS(Status)) { RtlCopyMemory(pStateInfo->FaceName, awchBuffer, sizeof(awchBuffer)); } // // Initial cursor size. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_CURSORSIZE, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->CursorSize = dwValue; } // // Initial history buffer size. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_HISTORYSIZE, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->HistoryBufferSize = dwValue; } // // Initial number of history buffers. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_HISTORYBUFS, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->NumberOfHistoryBuffers = dwValue; } // // Initial history duplication mode. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_HISTORYNODUP, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->HistoryNoDup = dwValue; } // // Initial text wrapping. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_LINEWRAP, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->fWrapText = dwValue; } // // Initial filter on paste. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_FILTERONPASTE, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->fFilterOnPaste = dwValue; } // // Initial ctrl shortcuts disabled. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_CTRLKEYSHORTCUTS_DISABLED, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->fCtrlKeyShortcutsDisabled = dwValue; } // // Initial line selection. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_LINESELECTION, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->fLineSelection = dwValue; } // // Initial transparency. // Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_WINDOWALPHA, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { if (dwValue <= BYTE_MAX) { pStateInfo->bWindowTransparency = (BYTE)dwValue; } } // Initial Cursor Color Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_CURSORCOLOR, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->CursorColor = dwValue; } // Initial Cursor Shape Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_CURSORTYPE, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->CursorType = dwValue; } // Initial Intercept Copy Paste Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_INTERCEPTCOPYPASTE, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->InterceptCopyPaste = !!dwValue; } // Initial Foreground Color Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_DEFAULTFOREGROUND, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->DefaultForeground = dwValue; } // Initial Background Color Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_DEFAULTBACKGROUND, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->DefaultBackground = dwValue; } // Initial Background Color Status = RegistrySerialization::s_QueryValue(hTitleKey, CONSOLE_REGISTRY_TERMINALSCROLLING, sizeof(dwValue), REG_DWORD, (PBYTE)&dwValue, NULL); if (NT_SUCCESS(Status)) { pStateInfo->TerminalScrolling = dwValue; } // // Close the registry keys // if (hTitleKey != hConsoleKey) { RegCloseKey(hTitleKey); } CloseKeys: RegCloseKey(hConsoleKey); RegCloseKey(hCurrentUserKey); return dwRet; }
CMainApp::Error_Codes CMainApp::ParseCommandLine(int argc, char ** argv) { char * pArgument; int count = 0; if(argc==1) m_dwFlags |= HELP; while(++count<argc) { pArgument = argv[count]; if(*pArgument=='/' || *pArgument=='-') { while(*(++pArgument)) { switch(*pArgument) { case 'a': // Append resources case 'A': { //Make sure no other conflicting flags are specified if(IsFlag(REPLACE) | IsFlag(UPDATE) | IsFlag(EXTRACT)) { Banner(); WriteCon(CONERR, "Please use -a without the -r, -u or -t option!"); return ERR_COMMAND_LINE; } // Make sure none of the next item is another option for(int c=1; c<=4; c++) if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-') { Banner(); WriteCon(CONERR, "Not enough parameters specified for the -a option\r\n"\ " -a InputExeFile InputUSTokFile InputLOCTokFile OutputExeFile\r\n"); return ERR_COMMAND_LINE; }; m_dwFlags |= APPEND; // Get the input EXE file name m_strInExe = argv[++count]; // Get the source token file name m_strSrcTok = argv[++count]; // Get the target token file name m_strTgtTok = argv[++count]; // Get the output EXE file name m_strOutExe = argv[++count]; } break; case 'b': case 'B': m_dwFlags |= BITMAPS; break; case 'd': case 'D': // Default for unmappable characters m_unmappedChar = argv[++count][0]; break; case 'f': case 'F': m_dwFlags |= FONTS; break; case 'i': // Input language/sublanguage case 'I': m_dwFlags |= INPUT_LANG; m_usIPriLangId = GetLangID(argv[++count]); m_usISubLangId = GetLangID(argv[++count]); break; case '?': // Help case 'h': case 'H': m_dwFlags |= HELP; break; case 'n': case 'N': m_dwFlags |= NOLOGO; break; case 'o': // Output language/sublanguage case 'O': m_dwFlags |= OUTPUT_LANG; m_usOPriLangId = GetLangID(argv[++count]); m_usOSubLangId = GetLangID(argv[++count]); break; case 'p': // Code page case 'P': m_uiCodePage = GetCodePage(argv[++count]); break; case 'r': // Replace resources case 'R': { //Make sure no other conflicting flags are specified if(IsFlag(APPEND) | IsFlag(EXTRACT) | IsFlag(UPDATE)) { Banner(); WriteCon(CONERR, "Please use -r without the -a, -u or -t option!"); return ERR_COMMAND_LINE; } // Make sure none of the next item is another option for(int c=1; c<=3; c++) if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-') { Banner(); WriteCon(CONERR, "Not enough parameters specified for the -r option\r\n"\ " -r InputExeFile InputLOCTokFile OutputExeFile\r\n"); return ERR_COMMAND_LINE; }; m_dwFlags |= REPLACE; // Get the input EXE file name m_strInExe = argv[++count]; // Get the target token file name m_strTgtTok = argv[++count]; // Get the output EXE file name m_strOutExe = argv[++count]; } break; case 'u': // Update resources case 'U': { //Make sure no other conflicting flags are specified if(IsFlag(APPEND) | IsFlag(EXTRACT) | IsFlag(REPLACE)) { Banner(); WriteCon(CONERR, "Please use -u without the -a, -r or -t option!"); return ERR_COMMAND_LINE; } // Make sure none of the next item is another option for(int c=1; c<=4; c++) if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-') { Banner(); WriteCon(CONERR, "Not enough parameters specified for the -u option\r\n"\ " -u InputExeFile InputUSTokFile InputLOCTokFile OutputExeFile\r\n"); return ERR_COMMAND_LINE; }; m_dwFlags |= UPDATE; // Get the input EXE file name m_strInExe = argv[++count]; // Get the source token file name m_strSrcTok = argv[++count]; // Get the target token file name m_strTgtTok = argv[++count]; // Get the output EXE file name m_strOutExe = argv[++count]; } break; case 's': case 'S': m_dwFlags |= SPLIT; break; case 't': // Create token file case 'T': { //Make sure no other conflicting flags are specified if(IsFlag(APPEND) | IsFlag(REPLACE) | IsFlag(UPDATE)) { Banner(); WriteCon(CONERR, "Please use -t without the -a, -u or -r option!"); return ERR_COMMAND_LINE; } // Make sure none of the next item is another option for(int c=1; c<=2; c++) if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-') { Banner(); WriteCon(CONERR, "Not enough parameters specified for the -t option\r\n"\ " -t InputExeFile OutputTokenFile\r\n"); return ERR_COMMAND_LINE; }; m_dwFlags |= EXTRACT; // Get the input EXE file name m_strInExe = argv[++count]; // Get the target token file name m_strTgtTok = argv[++count]; } break; case 'w': // Display warnings case 'W': m_dwFlags |= WARNING; break; default: break; } } } } // Do we want the banner if(!IsFlag(NOLOGO)) Banner(); // Before exiting make sure we display the help screen if requested if(IsFlag(HELP)) { Help(); return ERR_HELP_CHOOSE; } // Check if the code page we have is installed in this system if(!IsValidCodePage(m_uiCodePage)) { // Warn the user and get back the default CP m_uiCodePage = GetACP(); WriteCon(CONERR, "The code page specified is not installed in the system or is invalid! Using system default!\r\n"); } // Make sure the input file is there CFileStatus fs; if(!m_strInExe.IsEmpty()) { if(!CFile::GetStatus(m_strInExe, fs)) { WriteCon(CONERR, "File not found: %s\r\n", m_strInExe); return ERR_FILE_NOTFOUND; } } // Check if the tgt token file or exe are read only if(!m_strOutExe.IsEmpty()) { if(CFile::GetStatus(m_strOutExe, fs)) { if((fs.m_attribute & 0x1)==0x1) { WriteCon(CONERR, "File is read only: %s\r\n", m_strOutExe); return ERR_FILE_CREATE; } } } if(!m_strTgtTok.IsEmpty() && IsFlag(EXTRACT)) { if(CFile::GetStatus(m_strTgtTok, fs)) { if((fs.m_attribute & 0x1)==0x1) { WriteCon(CONERR, "File is read only: %s\r\n", m_strTgtTok); return ERR_FILE_CREATE; } } } // // Check the value specified for the output language. // If none has been specified, warn the user and default to neutral. // if(IsFlag(APPEND) | IsFlag(REPLACE)) { if(m_usOPriLangId==-1) { m_usOPriLangId = LANG_NEUTRAL; // set the PRI language ID to neutral WriteCon(CONERR, "Output language ID not specified, default to neutral(%d)\r\n", m_usOPriLangId); } if(m_usOSubLangId==-1) { m_usOSubLangId = SUBLANG_NEUTRAL; // set the SEC language ID to neutral WriteCon(CONERR, "Output sub-language ID not specified, default to neutral(%d)\r\n", m_usOSubLangId); } } WriteCon(CONWRN, "Code Page : %d\r\n", m_uiCodePage); WriteCon(CONWRN, "In Primary Language : %d (%d)\r\n", m_usIPriLangId, MAKELANGID(m_usIPriLangId,m_usISubLangId)); WriteCon(CONWRN, "In Secondary Language : %d (0x%x)\r\n", m_usISubLangId, MAKELANGID(m_usIPriLangId,m_usISubLangId)); WriteCon(CONWRN, "Out Primary Language : %d (%d)\r\n", m_usOPriLangId, MAKELANGID(m_usOPriLangId,m_usOSubLangId)); WriteCon(CONWRN, "Out Secondary Language : %d (0x%x)\r\n", m_usOSubLangId, MAKELANGID(m_usOPriLangId,m_usOSubLangId)); WriteCon(CONWRN, "Default unmapped char : %c \r\n", m_unmappedChar); return ERR_NOERROR; }
int main(int argc, char **argv) { DWORD cp; CPINFOEX info; struct cp *cur; int rnd = 0; /*if (argc < 2) { printf("Usage: cpinfoex cp_id\n"); return 0; } cp = atoi(argv[1]);*/ #if 0 /* Ref: http://www.iana.org/assignments/character-sets/character-sets.xhtml https://msdn.microsoft.com/en-us/goglobal/bb964653 http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/ */ #endif /* struct php_win32_cp { DWORD id; DWORD to_w_fl; DWORD from_w_fl; DWORD char_size; char *name; char *enc; char *desc; }; */ /*printf("struct php_win32_cp {\n\tDWORD id;\n\tDWORD to_w_fl;\n\tDWORD from_w_fl;\n\tDWORD char_size;\n\tchar *name;\n\tchar *enc;\n\tchar *desc;\n};\n\n"); */ printf("/* Autogenerated file. Update cp_enc_map_gen.c and regen like \n" " cp_enc_map_gen.exe > cp_enc_map.c \n*/\n\n"); printf("static const struct php_win32_cp php_win32_cp_map[] = {"); cur = &cp_map[0]; #ifdef ORDER_IT while (rnd <= 2 && ++rnd && (cur = &cp_map[0])) #endif while (cur->desc != NULL) { if (!IsValidCodePage(cur->id)) { #ifdef ORDER_IT if (2 == rnd) #endif printf("\t/* %u is invalid */\n", cur->id); //printf("#if 0\n\t{ %u, 0, \"%s\", \"%s\" },\n#endif\n", cur->id, cur->name, cur->desc); } else if (GetCPInfoEx(cur->id, 0, &info)) { DWORD to_w_fl = 0, from_w_fl = 0; if (65001U == cur->id || 54936U == cur->id) { from_w_fl = WC_ERR_INVALID_CHARS; to_w_fl = MB_ERR_INVALID_CHARS; } //printf("\t{ %u, %u, \"%s\", \"%s\" },\n", cur->id, info.MaxCharSize, cur->name, cur->desc); if (!cur->enc[0]) { #ifdef ORDER_IT if (2 == rnd) #endif //printf("\t/* { %u, %u, \"%s\", NULL, \"%s\" }, */\n", info.CodePage, info.MaxCharSize, cur->name, info.CodePageName); printf("\t{ %u, %u, %u, %u, \"%s\", NULL, \"%s\" },\n", info.CodePage, to_w_fl, from_w_fl, info.MaxCharSize, cur->name, info.CodePageName); } else { #ifdef ORDER_IT if (1 == rnd) #endif printf("\t{ %u, %u, %u, %u, \"%s\", \"%s\", \"%s\" },\n", info.CodePage, to_w_fl, from_w_fl, info.MaxCharSize, cur->name, cur->enc, info.CodePageName); } } cur++; } printf("};\n\n"); return 0; }
void loadThread() { char dic[1024]; char aff[1024]; #ifdef UNICODE mir_snprintf(dic, MAX_REGS(dic), "%S.dic", fileWithoutExtension); mir_snprintf(aff, MAX_REGS(aff), "%S.aff", fileWithoutExtension); #else mir_snprintf(dic, MAX_REGS(dic), "%s.dic", fileWithoutExtension); mir_snprintf(aff, MAX_REGS(aff), "%s.aff", fileWithoutExtension); #endif hunspell = new Hunspell(aff, dic); // Get codepage const char *dic_enc = hunspell->get_dic_encoding(); TCHAR *hwordchars; if (strcmp(dic_enc, "UTF-8") == 0) { codePage = CP_UTF8; #ifdef UNICODE int wcs_len; hwordchars = fromHunspell((char *) hunspell->get_wordchars_utf16(&wcs_len)); #else // No option hwordchars = NULL; #endif } else { for (int i = 0; i < MAX_REGS(codepages); i++) { if (_strcmpi(codepages[i].name, dic_enc) == 0) { if (IsValidCodePage(codepages[i].codepage)) codePage = codepages[i].codepage; break; } } hwordchars = fromHunspell(hunspell->get_wordchars()); } TCHAR *casechars = fromHunspellAndFree(get_casechars(dic_enc)); TCHAR *try_string = fromHunspellAndFree(hunspell->get_try_string()); wordChars = merge(merge(casechars, hwordchars), try_string); // Make a suggestion to load hunspell internalls char ** words = NULL; int count = hunspell->suggest(&words, "asdf"); for (int i = 0; i < count; i++) free(words[i]); if (words != NULL) free(words); loadCustomDict(); loaded = LANGUAGE_LOADED; }