win32localepeer.cpp
来自「这是VCF框架的代码」· C++ 代码 · 共 2,890 行 · 第 1/5 页
CPP
2,890 行
return result;}UnicodeString Win32LocalePeer::getNumberDecimalPoint(){ UnicodeString result; if ( System::isUnicodeEnabled() ) { VCFChar tmp[256]; GetLocaleInfoW( lcid_, LOCALE_SDECIMAL, tmp, 255 ); result = tmp; } else { char tmp[256]; GetLocaleInfoA( lcid_, LOCALE_SDECIMAL, tmp, 255 ); result = tmp; } return result;}UnicodeString Win32LocalePeer::getNumberGrouping(){ UnicodeString result; if ( System::isUnicodeEnabled() ) { VCFChar tmp[256]; GetLocaleInfoW( lcid_, LOCALE_SGROUPING, tmp, 255 ); result = tmp; } else { char tmp[256]; GetLocaleInfoA( lcid_, LOCALE_SGROUPING, tmp, 255 ); result = tmp; } return result;}UnicodeString Win32LocalePeer::getCurrencyDecimalPoint(){ UnicodeString result; if ( System::isUnicodeEnabled() ) { VCFChar tmp[256]; GetLocaleInfoW( lcid_, LOCALE_SMONDECIMALSEP, tmp, 255 ); result = tmp; } else { char tmp[256]; GetLocaleInfoA( lcid_, LOCALE_SMONDECIMALSEP, tmp, 255 ); result = tmp; } return result;}UnicodeString Win32LocalePeer::getCurrencyThousandsSeparator(){ UnicodeString result; if ( System::isUnicodeEnabled() ) { VCFChar tmp[256]; GetLocaleInfoW( lcid_, LOCALE_SMONTHOUSANDSEP, tmp, 255 ); result = tmp; } else { char tmp[256]; GetLocaleInfoA( lcid_, LOCALE_SMONTHOUSANDSEP, tmp, 255 ); result = tmp; } return result;}UnicodeString Win32LocalePeer::getCurrencySymbol(){ UnicodeString result; if ( System::isUnicodeEnabled() ) { VCFChar tmp[256]; GetLocaleInfoW( lcid_, LOCALE_SCURRENCY, tmp, 255 ); result = tmp; } else { char tmp[256]; GetLocaleInfoA( lcid_, LOCALE_SCURRENCY, tmp, 255 ); result = tmp; } return result;}int Win32LocalePeer::getCurrencyFractionalDigits(){ int result = 0; if ( System::isUnicodeEnabled() ) { VCFChar tmp[256]; GetLocaleInfoW( lcid_, LOCALE_ICURRDIGITS, tmp, 255 ); result = _wtoi(tmp); } else { char tmp[256]; GetLocaleInfoA( lcid_, LOCALE_ICURRDIGITS, tmp, 255 ); result = atoi(tmp); } return result;}UnicodeString Win32LocalePeer::getCurrencyPositiveSign(){ UnicodeString result; if ( System::isUnicodeEnabled() ) { VCFChar tmp[256]; GetLocaleInfoW( lcid_, LOCALE_SCURRENCY, tmp, 255 ); result = tmp; } else { char tmp[256]; GetLocaleInfoA( lcid_, LOCALE_SCURRENCY, tmp, 255 ); result = tmp; } return result;}UnicodeString Win32LocalePeer::getCurrencyNegativeSign(){ UnicodeString result; return result;}bool Win32LocalePeer::isCharA( const long& charTypeMask, const VCFChar& c ){ long mask = 0; UnicodeString oldLocaleStr; if ( System::isUnicodeEnabled() ) { #ifdef VCF_CW oldLocaleStr = setlocale( LC_CTYPE, NULL ); setlocale( LC_CTYPE, crtLocaleStr_.ansi_c_str() ); #else oldLocaleStr = _wsetlocale( LC_CTYPE, NULL ); _wsetlocale( LC_CTYPE, crtLocaleStr_.c_str() ); #endif if ( charTypeMask & ctSpace ) { if ( iswspace( c ) ) { mask |= ctSpace; } } if ( charTypeMask & ctPrint ) { if ( iswprint( c ) ) { mask |= ctPrint; } } if ( charTypeMask & ctCntrl ) { if ( iswprint( c ) ) { mask |= ctCntrl; } } if ( charTypeMask & ctCntrl ) { if ( iswcntrl( c ) ) { mask |= ctCntrl; } } if ( charTypeMask & ctUpper ) { if ( iswupper( c ) ) { mask |= ctUpper; } } if ( charTypeMask & ctLower ) { if ( iswlower( c ) ) { mask |= ctLower; } } if ( charTypeMask & ctDigit ) { if ( iswdigit( c ) ) { mask |= ctDigit; } } if ( charTypeMask & ctPunct ) { if ( iswpunct( c ) ) { mask |= ctPunct; } } if ( charTypeMask & ctHexDigit ) { if ( iswxdigit( c ) ) { mask |= ctHexDigit; } } if ( charTypeMask & ctAlpha ) { if ( iswalpha( c ) ) { mask |= ctAlpha; } } if ( charTypeMask & ctAlphaNumeric ) { if ( iswalnum( c ) ) { mask |= ctAlphaNumeric; } } if ( charTypeMask & ctGraph ) { if ( iswgraph( c ) ) { mask |= ctGraph; } } #ifdef VCF_CW setlocale( LC_CTYPE, oldLocaleStr.ansi_c_str() ); #else _wsetlocale( LC_CTYPE, oldLocaleStr.c_str() ); #endif } else { oldLocaleStr = setlocale( LC_CTYPE, NULL ); setlocale( LC_CTYPE, crtLocaleStr_.ansi_c_str() ); if ( charTypeMask & ctSpace ) { if ( isspace( c ) ) { mask |= ctSpace; } } if ( charTypeMask & ctPrint ) { if ( isprint( c ) ) { mask |= ctPrint; } } if ( charTypeMask & ctCntrl ) { if ( isprint( c ) ) { mask |= ctCntrl; } } if ( charTypeMask & ctCntrl ) { if ( iscntrl( c ) ) { mask |= ctCntrl; } } if ( charTypeMask & ctUpper ) { if ( isupper( c ) ) { mask |= ctUpper; } } if ( charTypeMask & ctLower ) { if ( islower( c ) ) { mask |= ctLower; } } if ( charTypeMask & ctDigit ) { if ( isdigit( c ) ) { mask |= ctDigit; } } if ( charTypeMask & ctPunct ) { if ( ispunct( c ) ) { mask |= ctPunct; } } if ( charTypeMask & ctHexDigit ) { if ( isxdigit( c ) ) { mask |= ctHexDigit; } } if ( charTypeMask & ctAlpha ) { if ( isalpha( c ) ) { mask |= ctAlpha; } } if ( charTypeMask & ctAlphaNumeric ) { if ( isalnum( c ) ) { mask |= ctAlphaNumeric; } } if ( charTypeMask & ctGraph ) { if ( isgraph( c ) ) { mask |= ctGraph; } } setlocale( LC_CTYPE, oldLocaleStr.ansi_c_str() ); } return (0 == mask) ? false : true;}UnicodeString Win32LocalePeer::translate( const UnicodeString& id ){ return "";}UnicodeString Win32LocalePeer::toStringFromDate( const DateTime& val, const UnicodeString& format ){ UnicodeString result; unsigned long y = val.getYear(); if ( ( y < 1601 ) || ( 30827 < y ) ) { throw RuntimeException( "The SYSTEMTIME structure doesn't allow dates outside the range [1601,30827]" ); } SYSTEMTIME timeVal = {0}; timeVal.wYear = y; timeVal.wMonth = val.getMonth(); timeVal.wDay = val.getDay(); timeVal.wDayOfWeek = val.getWeekDay(); int size = 0; DWORD flags = (!format.empty()) ? 0 : LOCALE_NOUSEROVERRIDE; if ( System::isUnicodeEnabled() ) { const VCFChar* formatStr = NULL; if ( !format.empty() ) { formatStr = format.c_str(); } size = GetDateFormatW( lcid_, flags, &timeVal, formatStr, NULL, 0 ); VCFChar* dateStr = new VCFChar[size+1]; memset(dateStr,0,(size+1)*sizeof(VCFChar)); GetDateFormatW( lcid_, flags, &timeVal, formatStr, dateStr, size ); result = dateStr; delete [] dateStr; } else { const char* formatStr = NULL; if ( !format.empty() ) { formatStr = format.ansi_c_str(); } size = GetDateFormatA( lcid_, flags, &timeVal, formatStr, NULL, 0 ); char* dateStr = new char[size+1]; memset(dateStr,0,(size+1)*sizeof(char)); GetDateFormatA( lcid_, flags, &timeVal, formatStr, dateStr, size ); result = dateStr; delete [] dateStr; } return result;}UnicodeString Win32LocalePeer::toStringFromTime( const DateTime& val, const UnicodeString& format ){ UnicodeString result; SYSTEMTIME timeVal = {0}; unsigned long y, m, d, h, min, s, ms; val.get( &y, &m, &d, &h, &min, &s, &ms ); if ( ( y < 1601 ) || ( 30827 < y ) ) { throw BasicException( "The SYSTEMTIME structure doesn't allow dates outside the range [1601,30827]" ); } timeVal.wYear = y; timeVal.wMonth = m; timeVal.wDayOfWeek = val.getWeekDay(); timeVal.wDay = d; timeVal.wHour = h; timeVal.wMinute = min; timeVal.wSecond = s; timeVal.wMilliseconds = ms; DWORD flags = (!format.empty()) ? 0 : LOCALE_NOUSEROVERRIDE; if ( System::isUnicodeEnabled() ) { const VCFChar* formatStr = NULL; if ( !format.empty() ) { formatStr = format.c_str(); } int size = GetTimeFormatW( lcid_, flags, &timeVal, formatStr, NULL, 0 ); VCFChar* dateStr = new VCFChar[size+1]; memset(dateStr,0,(size+1)*sizeof(VCFChar)); GetTimeFormatW( lcid_, flags, &timeVal, formatStr, dateStr, size ); result = dateStr; delete [] dateStr; } else { const char* formatStr = NULL; if ( !format.empty() ) { formatStr = format.ansi_c_str(); } int size = GetTimeFormatA( lcid_, flags, &timeVal, formatStr, NULL, 0 ); char* dateStr = new char[size+1]; memset(dateStr,0,(size+1)*sizeof(char)); GetTimeFormatA( lcid_, flags, &timeVal, formatStr, dateStr, size ); result = dateStr; delete [] dateStr; } return result;}ulong32 Win32LocalePeer::getLanguageCode(){ UINT languageID = PRIMARYLANGID(LANGIDFROMLCID(lcid_)); UINT subLangID = SUBLANGID(LANGIDFROMLCID(lcid_)); switch ( languageID ) { case LANG_AFRIKAANS : { return Locale::lcAfrikaans; } break; case LANG_ALBANIAN : { return Locale::lcAlbanian; } break; case LANG_ARABIC : { return Locale::lcArabic; } break; case LANG_ASSAMESE : { return Locale::lcAssamese; } break; case LANG_ARMENIAN : { return Locale::lcArmenian; } break; case LANG_AZERI : { return Locale::lcAzerbaijani; } break; case LANG_BASQUE : { return Locale::lcBasque; } break; case LANG_BELARUSIAN : { return Locale::lcBelarusian; } break; case LANG_BENGALI : { return Locale::lcBengali; } break; case LANG_BULGARIAN : { return Locale::lcBulgarian; } break; case LANG_CATALAN : { return Locale::lcCatalan; } break; case LANG_CHINESE : { return Locale::lcChinese; } break; case LANG_CROATIAN : { // equivalent to LANG_SERBIAN in winnt.h return Locale::lcSerbian; //??? Is this right??? } break; case LANG_CZECH : { return Locale::lcCzech; } break; case LANG_DANISH : { return Locale::lcDanish; } break; case LANG_DUTCH : { return Locale::lcDutch; } break; case LANG_ENGLISH : { return Locale::lcEnglish; } break; case LANG_ESTONIAN : { return Locale::lcEstonian; } break; case LANG_FAEROESE : { return Locale::lcFaroese; } break; case LANG_FARSI : { return Locale::lcPersian; //?? do we need others ? Afghanistan?? } break; case LANG_FINNISH : { return Locale::lcFinnish; } break; case LANG_FRENCH : { return Locale::lcFrench; } break; case LANG_GEORGIAN : { return Locale::lcGeorgian; } break; case LANG_GERMAN : { return Locale::lcGerman; } break; case LANG_GREEK : { return Locale::lcGreek; } break; case LANG_GUJARATI : { return Locale::lcGujarati; } break; case LANG_HEBREW : { return Locale::lcHebrew; } break; case LANG_HINDI : { return Locale::lcHindi;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?