/* static */ void ConfigFile::trim( wstring& s ) { // Remove leading and trailing whitespace static const wchar_t whitespace[] = L" \n\t\v\r\f"; s.erase( 0, s.find_first_not_of(whitespace) ); s.erase( s.find_last_not_of(whitespace) + 1U ); }
void GetXMLMessage(wstring &msg, wstring &type) { msg = xml_message; type = xml_message_type; xml_message.erase(); xml_message_type.erase(); }
static void string_strip_quotes(wstring& s) { static const wchar_t* empties = L" \t\n\r"; if (s[s.length()-1]=='"') s.erase(s.length()-1); if (s[0]=='"') s.erase(0,1); }
static void string_strip(wstring& s) { static const wchar_t* empties = L" \t\n\r"; int e = s.find_last_not_of(empties); s.erase(e + 1); int b = s.find_first_not_of(empties); s.erase(0,b); }
void trim(wstring& str) { wstring::size_type pos = str.find_last_not_of(' '); if(pos != string::npos) { str.erase(pos + 1); pos = str.find_first_not_of(' '); if(pos != string::npos) str.erase(0, pos); } else str.erase(str.begin(), str.end()); }
EncodingType getEncodingType( wstring& text ) { // UTF8 if (text.size() >= 3 && text[0] == (wchar_t)0xEF && text[1] == (wchar_t)0xBB && text[2] == (wchar_t)0xBF) { text.erase(0, 3); return(UTF8); } // UTF32_BigEndian if (text.size() >= 4 && text[0] == (wchar_t)0x00 && text[1] == (wchar_t)0x00 && text[2] == (wchar_t)0xFE && text[3] == (wchar_t)0xFF) { text.erase(0, 4); return(UTF32_BigEndian); } // UTF32_LittleEndian if (text.size() >= 4 && text[0] == (wchar_t)0xFF && text[1] == (wchar_t)0xFE && text[2] == (wchar_t)0x00 && text[3] == (wchar_t)0x00) { text.erase(0, 4); return(UTF32_LittleEndian); } // UTF16_BigEndian if (text.size() >= 2 && text[0] == (wchar_t)0xFE && text[1] == (wchar_t)0xFF) { text.erase(0, 2); return(UTF16_BigEndian); } // UTF16_LittleEndian if (text.size() >= 2 && text[0] == (wchar_t)0xFF && text[1] == (wchar_t)0xFE) { text.erase(0, 2); return(UTF16_LittleEndian); } return(ANSI); }
wstring trim(wstring str) { wstring::iterator it = str.begin(); while (str.begin() != str.end() && *str.begin() == L' ') str.erase(str.begin()); while (str.begin() != str.end()) { it = str.end() - 1; if (*it != L' ') break; str.erase(it); } return str; }
//Delete white spaces from the end and the begining of the string wstring Utils::trim(wstring str) { wstring::iterator it; while ((str.length()>0)&&((*(it=str.begin()))==L' ')) { str.erase(it); } while ((str.length()>0)&&((*(it=(str.end()-1)))==L' ')) { str.erase(it); } return str; }
void O2Profile:: GetPubkeyW(wstring &out) const { out.erase(); PubKey.to_string(out); }
/* ----------------------------------------------------------------------- * 関数名 : cutbom * 機能概要: wstring先頭にUCS-2 BOMがあったら取り除く * ----------------------------------------------------------------------- */ void cutbom(wstring &wstr) { if (wstr.size() < 2) return; if (wstr[0] == (wchar_t)0xfeff || wstr[0] == (wchar_t)0xffef) wstr.erase(0, 1); }
void vmsHttpFlvTrafficAnalyzer::ExtractTitleFromHtml(const vmsHttpTrafficCollector::HttpDialog *pHtmlDlg, wstring &wstrTitle) { wstrTitle = L""; UINT codePage = 0; ExtractCodePageFromHtml (pHtmlDlg, codePage); if (!codePage) codePage = pHtmlDlg->codePage; assert (pHtmlDlg != NULL); if (!pHtmlDlg) return; if (pHtmlDlg->vbResponseBody.empty ()) return; LPCSTR psz = strstrni ((LPCSTR)&pHtmlDlg->vbResponseBody [0], "<title>", pHtmlDlg->vbResponseBody.size ()); if (psz) { psz += 7; LPCSTR pszEnd = (LPCSTR)&pHtmlDlg->vbResponseBody [0] + pHtmlDlg->vbResponseBody.size (); string strTitle; while (psz < pszEnd) { if (*psz != '<') strTitle += *psz++; else break; } if (*psz == '<' && !strTitle.empty ()) { vmsCharsets::DecodeString (strTitle.c_str (), codePage ? codePage : CP_UTF8, wstrTitle); while (wstrTitle.empty () == false && wstrTitle [0] <= ' ') wstrTitle.erase (wstrTitle.begin ()); while (wstrTitle.empty () == false && wstrTitle [wstrTitle.length ()-1] <= ' ') wstrTitle.erase (wstrTitle.end ()-1); for (int i = 0; i < wstrTitle.length (); i++) { if (wstrTitle [i] < ' ') wstrTitle [i] = ' '; if (i && wstrTitle [i] == ' ' && wstrTitle [i-1] == ' ') wstrTitle.erase (wstrTitle.begin () + i--); } } } }
bool Inet::StatusCodeAnalysis(wstring sctext,int* res){ int i,n,pos; wchar_t *err; if(pos=sctext.find(' ')==wstring::npos){ return false; } sctext.erase(0,pos+1); if(pos=sctext.find(' ')==wstring::npos){ return false; } sctext.erase(pos); *res=wcstol(sctext.c_str(),&err,10); if(lstrlen(err)!=0){ return false; } return true; }
/* ----------------------------------------------------------------------- * 関数名 : ws_eraseend * 機能概要: wstringの終端からcを削る * ----------------------------------------------------------------------- */ void ws_eraseend(wstring &str, wchar_t c) { int len = str.size(); if (!len) return; if (str[len - 1] == c) str.erase(str.end() - 1); }
void prepareString(wstring & str) { str.erase(remove_if(str.begin(), str.end(), [](wchar_t const ch) { return ch == ' ' || ch == '\\' || ch == '-'; }), str.end()); for (wchar_t & ch : str) ch = tolower(ch); }
wstring getNameFromSoundString(wstring sSoundString) { size_t end = sSoundString.rfind(TEXT(".flac")); size_t start = sSoundString.rfind('.', end-1); if(start == wstring::npos || end == wstring::npos) //Not any numbers heres return sSoundString; sSoundString.erase(start, end-start); //Erase the numbers in the middle return sSoundString; //Done }
void StrUtils::trimleft(wstring& s ) { wstring::iterator it; for( it = s.begin(); it != s.end(); it++ ) if( !StrUtils::isspace(*it)) break; s.erase( s.begin(), it ); }
/// <summary> /// Trims out any trailing zeros or decimals in the given input string /// </summary> /// <param name="input">wstring to trim</param> void UnitConverter::TrimString(wstring& returnString) { if (returnString.find(L'.') != m_returnDisplay.npos) { wstring::iterator iter; for (iter = returnString.end() - 1; ;iter--) { if (*iter != L'0') { returnString.erase(iter + 1, returnString.end()); break; } } if (*(returnString.end()-1) == L'.') { returnString.erase(returnString.end()-1, returnString.end()); } } }
void StringUtilities::ReplaceAll(wstring &str, const wstring &search, const wstring &replace) { for (size_t pos = 0;; pos += replace.length() - 1) { pos = str.find(search, pos); if (pos == string::npos) break; str.erase(pos, search.length()); str.insert(pos, replace); } }
void Trim(wstring& str, const wchar_t trim_chars[], bool trim_left, bool trim_right) { if (str.empty()) return; const size_t index_begin = trim_left ? str.find_first_not_of(trim_chars) : 0; const size_t index_end = trim_right ? str.find_last_not_of(trim_chars) : str.length() - 1; if (index_begin == wstring::npos || index_end == wstring::npos) { str.clear(); return; } if (trim_right) str.erase(index_end + 1, str.length() - index_end + 1); if (trim_left) str.erase(0, index_begin); }
//---------------------------------------------------------------------- // Converts a UTF8 encoded string to a unicode string // See the following document for more information: // RFC2279: UTF-8, a transformation format of ISO 10646 // Author: pdaehne //---------------------------------------------------------------------- void TextFace::convertUTF8ToUnicode(const string &utf8Text, wstring &text) { // Clear and prepare the result string text.erase(); text.reserve(utf8Text.length()); // Transform UTF8 sequences to UTF16 sequences const char *pos = utf8Text.c_str(); while (*pos != '\0') text.append(1, utf8Char2Unicode(pos)); }
void EraseChars(wstring& str, const wchar_t chars[]) { size_t pos = 0; do { pos = str.find_first_of(chars, pos); if (pos != wstring::npos) str.erase(pos, 1); } while (pos != wstring::npos); }
std::string CAndorSDK3Camera::GenerateCameraName(unsigned cameraID, wstring & cameraModelCheck) { string s_cameraName("Neo 5.5 "); if (CIDZyla == cameraID) { try { cameraModelCheck.erase(8); } catch (const std::out_of_range&) { cameraModelCheck.erase(); } s_cameraName = "Zyla 5.5 "; if (0 == cameraModelCheck.compare(L"ZYLA-4.2") ) { s_cameraName = "Zyla 4.2 "; } } return s_cameraName; }
void WONCommon::StringToWString(const char* src, size_t pos, size_t n, wstring& dst) { if (!src || !*src || !n) dst.erase(); else { size_t aStrSize = strnlen(src, pos + n); if (aStrSize <= pos) dst.erase(); else { size_t aCopySize = aStrSize - pos; wchar_t* aBuf = new wchar_t[aCopySize + 1]; AsciiToWide(aBuf, src + pos, aCopySize); aBuf[aCopySize] = 0; dst = aBuf; delete[] aBuf; } } }
void StrUtils::trimright( wstring& s ) { wstring::difference_type dt; wstring::reverse_iterator it; for( it = s.rbegin(); it != s.rend(); it++ ) if( !StrUtils::isspace( *it ) ) break; dt = s.rend() - it; s.erase( s.begin() + dt, s.end() ); }
void EraseLeft(wstring& str1, const wstring& str2, bool case_insensitive) { if (str1.length() < str2.length()) return; if (case_insensitive) { if (!std::equal(str2.begin(), str2.end(), str1.begin(), &IsCharsEqual)) return; } else { if (!std::equal(str2.begin(), str2.end(), str1.begin())) return; } str1.erase(str1.begin(), str1.begin() + str2.length()); }
void WONCommon::StringToWString(const string& src, wstring& dst) { size_t aStrSize = src.size(); if (!aStrSize) dst.erase(); else { wchar_t* aBuf = new wchar_t[aStrSize + 1]; AsciiToWide(aBuf, src.data(), aStrSize); aBuf[aStrSize] = 0; dst = aBuf; delete[] aBuf; } }
CAndorSDK3Camera::CameraId CAndorSDK3Camera::DetermineCameraId(wstring & cameraSerialCheck) { CameraId id = CIDNeo; try { cameraSerialCheck.erase(4); if (0 == cameraSerialCheck.compare(L"VSC-") ) { id = CIDZyla; } } catch (const std::out_of_range&) { } return id; }
wstring Parser::getInputName(wstring content) { wstring name = L""; content.erase(remove(content.begin(), content.end(), '\t'), content.end()); wstring contentInfo = content; const wregex re(L"(<input[^>]*name=['|\"](.*?)['|\"].*?>)", regex::icase); wsmatch results; if (regex_match(contentInfo.cbegin(), contentInfo.cend(), results, re)) { name = results[1]; wcout << "Name = " << name << endl; } return name; }
wstring Parser::getSpanstyle(wstring content) { wstring style = L""; content.erase(remove(content.begin(), content.end(), '\t'), content.end()); wstring contentInfo = content; const wregex re(L"(<span[^>]*style=['|\"](.*?)['|\"].*?>)", regex::icase); wsmatch results; if (regex_match(contentInfo.cbegin(), contentInfo.cend(), results, re)) { style = results[2]; wcout << "Name = " << style << endl; } return style; }
wstring Parser::getHyperRef(wstring content) { wstring href = L""; content.erase(remove(content.begin(), content.end(), '\t'), content.end()); wstring contentInfo = content; const wregex re(L"(<a[^>]*href=['|\"](.*?)['|\"].*?>)", regex::icase); wsmatch results; if (regex_match(contentInfo.cbegin(), contentInfo.cend(), results, re)) { href = results[2]; wcout << "Name = " << href << endl; } return href; }