/** * Escape the special XML characters and be careful to catch any disallowed control character */ QString CheckAndEscapeXmlText(const QString& strText) { QString strReturn(strText); QChar ch; for (uint i=0; i<strReturn.length(); i++) { ch = strReturn[i]; const int test = ch.unicode(); // The i+= is for the additional characters if (test == 38) { strReturn.replace(i, 1, "&"); i+=4; } // & else if (test == 60) { strReturn.replace(i, 1, "<"); i+=3; } // < else if (test == 62) { strReturn.replace(i, 1, ">"); i+=3; } // > else if (test == 34) { strReturn.replace(i, 1, """); i+=5; } // " else if (test == 39) { strReturn.replace(i, 1, "'"); i+=5; } // ' else if (test >= 32) continue; // Normal character (from space on) else if ((test == 9) || (test == 10) || (test == 13) ) continue; // Allowed control characters: TAB, LF, CR else { // A disallowed control character: // - could be a bug in the RTF file // - could be not supported encoding. // In any case, we must replace this character. kDebug(30515) <<"Control character in XML stream:" << test; strReturn.replace(i, 1, '?'); // Replacement character } } return strReturn; }
wxString DatabaseStringConverter::ConvertFromUnicodeStream(const char* inputBuffer, const char* encoding) { wxString strReturn(wxConvUTF8.cMB2WC(inputBuffer), *wxConvCurrent); // If the UTF-8 conversion didn't return anything, then try the default unicode conversion if (strReturn == wxEmptyString) strReturn << wxString(inputBuffer, *wxConvCurrent); return strReturn; }
const CString CWindowsError::GetMessage() const{ LPCWSTR szMessage = 0; if(FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, this->m_dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&szMessage, 1, 0)){ CString strReturn(szMessage); LocalFree((HLOCAL)szMessage); return strReturn; } return L"Error nr " + String::ToString(this->m_dwErrorCode); }
/// /// \brief Fonction qui permet de remplacer toutes les occurences d'une string par une autre /// \param[in] strSource String source /// \param[in] strFind String qu'on veut remplacer /// \param[in] strReplace String de remplacement /// \return La string strSource sans les encodages html /// std::string String::Replace(const std::string &strSource, const std::string &strFind, const std::string &strReplace) { std::string strReturn(strSource); unsigned int pos=0; while((pos=strReturn.find(strFind, pos))!=std::string::npos) { strReturn.replace(pos, strFind.size(),strReplace); pos+=strReplace.size(); } return strReturn; }
std::string WStringToUTF8(const wchar_t* lpwcszWString) { char* pElementText; int iTextLen = ::WideCharToMultiByte(CP_UTF8, 0, (LPWSTR)lpwcszWString, -1, NULL, 0, NULL, NULL); pElementText = new char[iTextLen + 1]; memset((void*)pElementText, 0, (iTextLen + 1) * sizeof(char)); ::WideCharToMultiByte(CP_UTF8, 0, (LPWSTR)lpwcszWString, -1, pElementText, iTextLen, NULL, NULL); std::string strReturn(pElementText); delete [] pElementText; return strReturn; }
std::string ProtocolSartano::getStringForCode(const std::wstring &strCode, int method) { std::string strReturn("S"); for (size_t i = 0; i < strCode.length(); ++i) { if (strCode[i] == L'1') { strReturn.append("$k$k"); } else { strReturn.append("$kk$"); } } if (method == TELLSTICK_TURNON) { strReturn.append("$k$k$kk$$k+"); } else if (method == TELLSTICK_TURNOFF) { strReturn.append("$kk$$k$k$k+"); } else { return ""; } return strReturn; }
/// /// \brief Fonction qui remplace les encodages html /// \param[in] strSource String source /// \return La string strSource sans les encodages html /// std::string HtmlDecode(const std::string &strSource) { std::string strReturn(strSource); if(Utils::String::Contains(strReturn, ";")) //TODO:remplacer par Regex avec & ; { //Décodage des principaux caractère de la langue française //Ajout au besoin //http://www.ascii.cl/htmlcodes.htm strReturn=Utils::String::Replace(strReturn, "à", "à"); strReturn=Utils::String::Replace(strReturn, "á", "á"); strReturn=Utils::String::Replace(strReturn, "â", "â"); strReturn=Utils::String::Replace(strReturn, "ä", "ä"); strReturn=Utils::String::Replace(strReturn, "è", "è"); strReturn=Utils::String::Replace(strReturn, "é", "é"); strReturn=Utils::String::Replace(strReturn, "ê", "ê"); strReturn=Utils::String::Replace(strReturn, "ë", "ë"); strReturn=Utils::String::Replace(strReturn, "ì", "ì"); strReturn=Utils::String::Replace(strReturn, "í", "í"); strReturn=Utils::String::Replace(strReturn, "î", "î"); strReturn=Utils::String::Replace(strReturn, "ï", "ï"); strReturn=Utils::String::Replace(strReturn, "ò", "ò"); strReturn=Utils::String::Replace(strReturn, "ó", "ó"); strReturn=Utils::String::Replace(strReturn, "ô", "ô"); strReturn=Utils::String::Replace(strReturn, "ö", "ö"); strReturn=Utils::String::Replace(strReturn, "ù", "ù"); strReturn=Utils::String::Replace(strReturn, "ú", "ú"); strReturn=Utils::String::Replace(strReturn, "û", "û"); strReturn=Utils::String::Replace(strReturn, "ü", "ü"); strReturn=Utils::String::Replace(strReturn, "ç", "ç"); strReturn=Utils::String::Replace(strReturn, " ", " "); //Version Majuscule strReturn=Utils::String::Replace(strReturn, "À", "À"); strReturn=Utils::String::Replace(strReturn, "Á", "Á"); strReturn=Utils::String::Replace(strReturn, "Â", "Â"); strReturn=Utils::String::Replace(strReturn, "Ä", "Ä"); strReturn=Utils::String::Replace(strReturn, "È", "È"); strReturn=Utils::String::Replace(strReturn, "É", "É"); strReturn=Utils::String::Replace(strReturn, "Ê", "Ê"); strReturn=Utils::String::Replace(strReturn, "Ë", "Ë"); strReturn=Utils::String::Replace(strReturn, "Ì", "Ì"); strReturn=Utils::String::Replace(strReturn, "Í", "Í"); strReturn=Utils::String::Replace(strReturn, "Î", "Î"); strReturn=Utils::String::Replace(strReturn, "Ï", "Ï"); strReturn=Utils::String::Replace(strReturn, "Ò", "Ò"); strReturn=Utils::String::Replace(strReturn, "Ó", "Ó"); strReturn=Utils::String::Replace(strReturn, "Ô", "Ô"); strReturn=Utils::String::Replace(strReturn, "Ö", "Ö"); strReturn=Utils::String::Replace(strReturn, "Ù", "Ù"); strReturn=Utils::String::Replace(strReturn, "Ú", "Ú"); strReturn=Utils::String::Replace(strReturn, "Û", "Û"); strReturn=Utils::String::Replace(strReturn, "Ü", "Ü"); strReturn=Utils::String::Replace(strReturn, "Ç", "Ç"); strReturn=Utils::String::Replace(strReturn, " ",""); strReturn=Utils::String::Replace(strReturn, "ê","ê"); strReturn=Utils::String::Replace(strReturn, "é","é"); strReturn=Utils::String::Replace(strReturn, "ë","ë"); strReturn=Utils::String::Replace(strReturn, "â","â"); strReturn=Utils::String::Replace(strReturn, "ô","ô"); strReturn=Utils::String::Replace(strReturn, "—","-"); } if(Utils::String::Contains(strReturn, "Ã")) { strReturn=Utils::String::Replace(strReturn, "ô", "ô"); strReturn=Utils::String::Replace(strReturn, "ê", "ê"); strReturn=Utils::String::Replace(strReturn, "â", "â"); strReturn=Utils::String::Replace(strReturn, "é", "é"); strReturn=Utils::String::Replace(strReturn, "ë", "ë"); strReturn=Utils::String::Replace(strReturn, "è", "è"); strReturn=Utils::String::Replace(strReturn, "à ", "à"); strReturn=Utils::String::Replace(strReturn, "ç", "ç"); strReturn=Utils::String::Replace(strReturn, "Â", "Â"); strReturn=Utils::String::Replace(strReturn, "À", "À"); strReturn=Utils::String::Replace(strReturn, "É", "É"); strReturn=Utils::String::Replace(strReturn, "Ê", "Ê"); strReturn=Utils::String::Replace(strReturn, "ÃŽ", "Î"); } if(Utils::String::Contains(strReturn, "â")) { strReturn=Utils::String::Replace(strReturn, "–", "-"); } return strReturn; }
// Uppercases the specified string. CString CTemplateFormater::FormatUpper(const CString& szSource) { CString strReturn(szSource); strReturn.MakeUpper(); return strReturn; };
std::string URLEncode(const std::string str) { std::string strReturn(str); Replace(strReturn, ";", "%3B"); return strReturn; }
int CTranCmn::fnAPP_SelectMenu() { CString strReturn(""); return T_OK; }
int CTranCmn::fnAPP_IBK_MANAGEMENT_InputProc() { CString ManagerOpPassword("00000000"); CString KtLinKusOpPassword("0000"); CString strReturn(""); CString strTmp(""); int nGetCnt = 0; CString strAcceptLen("0"); ///////////////////////////////////////////////////////////////////////////// Accept.AuthFlag = 0; ///////////////////////////////////////////////////////////////////////////// m_pDevCmn->fnSCR_DisplayScreen(3200, K_30_WAIT, PIN_MENU_MODE1); // 환경 업체선택 strReturn = m_pDevCmn->fstrSCR_GetKeyString(); if (strReturn == "NICE") { ManagerOpPassword.Format("%8.8s", GetDate()); Accept.AuthFlag = 1; strAcceptLen = "8"; } else if (strReturn == "KT LINKUS") { KtLinKusOpPassword = "******"; Accept.AuthFlag = 2; strAcceptLen = "4"; } else if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_TIMEOVER) fnAPP_CancelProc(T_TIMEOVER); else if (strReturn == S_INPUTOVER) fnAPP_CancelProc(T_INPUTOVER); else { fnAPP_CancelProc(T_INPUTOVER); } while (TRUE) { if(nGetCnt > 2) fnAPP_CancelProc(T_INPUTOVER); m_pDevCmn->fnSCR_DisplayString(1, strAcceptLen); // #0115 m_pDevCmn->fnSCR_DisplayScreen(3202, K_30_WAIT, PIN_NUMERIC_MODE); strReturn = m_pDevCmn->fstrSCR_GetKeyString(); if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_TIMEOVER) fnAPP_CancelProc(T_TIMEOVER); else if (strReturn == S_INPUTOVER) fnAPP_CancelProc(T_INPUTOVER); else if (strReturn == S_CLEAR) { nGetCnt++; continue; } else { if (Accept.AuthFlag == 2) { if (strReturn == KtLinKusOpPassword) { break; } else { nGetCnt++; continue; } } else { if (strReturn == ManagerOpPassword) { break; } else { nGetCnt++; continue; } } } } strReturn = ""; ///////////////////////////////////////////////////////////////////////////// memset(Accept.JiroElecNum, '0', sizeof(Accept.JiroElecNum)); // 환경점검내용 ///////////////////////////////////////////////////////////////////////////// //#N0214 strTmp = IniGetStr(_TRANS_INI, TRANS_SEC, "IBK_MANAGEMENT_INFO","00000000000000"); //#N0199 환경점검 이전 내용 표시 //#N0213 환경점검 시 초기 상태 무조건 비정상 //strTmp = "11111111111111"; //#N0214 m_pDevCmn->fnSCR_DisplayString(1, strTmp); m_pDevCmn->fnSCR_DisplayScreen(3201, K_120_WAIT, PIN_MENU_MODE1); // 환경점검내용 strReturn = m_pDevCmn->fstrSCR_GetKeyString(); if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_TIMEOVER) fnAPP_CancelProc(T_TIMEOVER); else if (strReturn == S_INPUTOVER) fnAPP_CancelProc(T_INPUTOVER); else if ((strReturn.GetLength() != 14) || // 자료검증 (!IsNum(strReturn.GetBuffer(0), strReturn.GetLength())) ) fnAPP_CancelProc(T_INPUTERROR); else { Accept.JiroElecNumSize = strReturn.GetLength(); memcpy(Accept.JiroElecNum, strReturn.GetBuffer(0), strReturn.GetLength()); strTmp.Empty(); strTmp = strReturn; IniSetStr(_TRANS_INI, TRANS_SEC, "IBK_MANAGEMENT_INFO", strReturn.GetBuffer(0)); //#N0199 환경점검 이전 내용 표시 -> #N0214 } strReturn = ""; ///////////////////////////////////////////////////////////////////////////// Accept.TelNumSize = 0; // 직원번호 memset(Accept.TelNum, ' ', sizeof(Accept.TelNum)); // 직원번호 ///////////////////////////////////////////////////////////////////////////// m_pDevCmn->fnSCR_DisplayScreen(3203, K_30_WAIT, PIN_NUMERIC_MODE); //// 직원번호 strReturn = m_pDevCmn->fstrSCR_GetKeyString(); if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_TIMEOVER) fnAPP_CancelProc(T_TIMEOVER); else if (strReturn == S_INPUTOVER) fnAPP_CancelProc(T_INPUTOVER); else if ((!strReturn.GetLength()) || // 자료검증 (strReturn.GetLength() > sizeof(Accept.TelNum)) || (!IsNum(strReturn.GetBuffer(0), strReturn.GetLength())) || (IsZero(strReturn.GetBuffer(0), strReturn.GetLength()))) fnAPP_CancelProc(T_INPUTERROR); else { Accept.TelNumSize = strReturn.GetLength(); memcpy(Accept.TelNum, strReturn.GetBuffer(0), strReturn.GetLength()); IniSetStr(_TRANS_INI, TRANS_SEC, "IBK_MANAGEMENT_INFO", strTmp); //#N0199 환경점검 이전 내용 표시 } return T_OK; }