46 const std::wstring& s,
49 bool bCaseInsensitive)
51 std::wstring new_string(s);
52 size_t str1Len = (str1 !=
nullptr) ? wcslen(str1) : 0;
55 if (!s.empty() && str1Len > 0 && str2 !=
nullptr)
57 bool bReplaced =
false;
59 const wchar_t* pStart = s.c_str();
60 const wchar_t* pEnd = pStart + s.length();
66 const wchar_t* pFound =
nullptr;
75 pFound = wcsstr(pStart, str1);
79 if (pFound !=
nullptr)
83 out.append(pStart, pFound - pStart);
87 pStart = pFound + str1Len;
136 const std::wstring& s,
139 bool bCaseInsensitive)
141 std::wstring str1(1, c1);
142 std::wstring str2(1, c2);
143 return (
Replace(s, str1.c_str(), str2.c_str(), bCaseInsensitive));
Declaration of the Replace() functions, for replacing characters and strings in a string.
The namespace containing all the "helper" functions in the C++ code.
wchar_t * wcsstri(const wchar_t *s1, const wchar_t *s2)
Do case-insensitive search for string 2 (s2) in string 1 (s1). Similar to the C library's wcsstr().
std::string Replace(const std::string &s, const char *str1, const char *str2, bool bCaseInsensitive)
Replace all occurrences of narrow string str1 with narrow string str2 in s. If str2 is empty then all...
Declaration of the wcsstri function, case-insensitive string search for wide character strings.